Your question is Prevent SQL Injection With Validation. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Write a function to validate input data to prevent SQL injection.
Implement validate_input(data), where data is a list of filter dictionaries. Return True only when every filter has an allowed field, operator, and correctly typed value. Reject malformed structures, unsupported values, control characters, and common SQL injection delimiters or comment markers. The validator must accept ordinary apostrophes in names, such as O'Reilly.
data is a JSON-compatible list. Each item must contain exactly field, operator, and value. Return a boolean.
def validate_input(data):