The monday Work Management API receives a batch of user-submitted item updates. Write a function that validates and normalizes the batch efficiently while preserving the order of accepted updates.
An update is valid when it is a dictionary containing item_id, column, and value where:
item_id is a positive integer, but booleans are not accepted.column is a string whose surrounding whitespace is removed, and whose normalized value appears in allowed_columns.value is a string whose surrounding whitespace is removed, is not empty, and has at most 100 characters.(item_id, column) pair. If a duplicate occurs, reject the later update.Return a dictionary with two fields: valid, containing normalized update dictionaries, and invalid_indices, containing the zero-based indices of every rejected update in input order. Invalid updates must not reserve their item-column pair.
def validate_updates(updates, allowed_columns):