_validate_sequence(value_type,
value,
errors=None)
Validates a sequence value.
Returns a list of validation errors generated during the validation. If
no errors are generated, returns an empty list.
value_type is a field. value is the sequence being validated. errors is
an optional list of errors that will be prepended to the return value.
To illustrate, we'll use a text value type. All values must be unicode.
>>> field = TextLine(required=True)
To validate a sequence of various values:
>>> errors = _validate_sequence(field, ('foo', u'bar', 1))
>>> errors
[foo <type 'unicode'>, 1 <type 'unicode'>]
The only valid value in the sequence is the second item. The others
generated errors.
We can use the optional errors argument to collect additional errors
for a new sequence:
>>> errors = _validate_sequence(field, (2, u'baz'), errors)
>>> errors
[foo <type 'unicode'>, 1 <type 'unicode'>, 2 <type 'unicode'>]
-
|