formencode.foreach – Validate items in a list¶
Validator for repeating items.
Use this to apply a validator/converter to each item in a list.
ForEach(AsInt(), InList([1, 2, 3]))
Will take a list of values and try to convert each of them to an integer, and then check if each integer is 1, 2, or 3. Using multiple arguments is equivalent to:
ForEach(All(AsInt(), InList([1, 2, 3])))
Use convert_to_list=True if you want to force the input to be a list. This will turn non-lists into one-element lists, and None into the empty list. This tries to detect sequences by iterating over them (except strings, which aren’t considered sequences).
ForEach will try to convert the entire list, even if errors are encountered. If errors are encountered, they will be collected and a single Invalid exception will be raised at the end (with error_list set).
If the incoming value is a set, then we return a set.
- The input must be a string (not a
- Please enter a value
- The input must be a string (not None)