Your question is Validate Input Against Policies. 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.
Intercom Inbox receives user-submitted text that must satisfy configurable security policies before processing. Implement a validator that checks an ASCII string against an ordered list of policies and returns the names of every policy it violates.
Implement validate_input(text, policies), where text is a string and policies is a list of dictionaries. Each dictionary contains a unique name, a type, and, when required, a value:
min_length: value is the minimum number of characters.max_length: value is the maximum number of characters.must_include: value is one of lowercase, uppercase, digit, or special.forbid_substring: value is a case-insensitive substring that must not occur.max_consecutive: value is the maximum number of identical consecutive characters.Return a list of policy names violated by text, preserving the order of policies. Return an empty list when all policies pass.
def validate_input(text, policies):