All validation exceptions will be subclasses of this exception.
Lists of validation errors for each field in a validator.
Only filled out for a field if the field has an error.
A dict with the validation exceptions for all fields that failed validation. Normal field errors will be a
ValidationExceptioninstance, while errors for
NestedValidatormay also be
Yield a pair of
(path, errors)for each error.
>>> list(errors.flatten()) [ (['bar'], ['Unknown field']), (['foo'], ['This field can not be empty']), ]
If an error is a
InvalidDataException, then errors are recursively extracted.
pathwill be an array of the path to the error.
errorswill be an array of the error messages from these errors.
If validator was constructed for a shopping cart, which had user details and a list of items in a shopping cart, made using a
ListField, some possible flattened errors might be:
>>> list(errors.flatten()) [ (['name'], ['This field can not be empty']), (['items', 2, 'quantity'], ['This must be equal to or greater than the minimum of 1']), ]
ValidationException(message, code, **kwargs)¶
A field has failed validation.
The validation error as a human readable string. This error is translatable via gettext, and should not be used for checking the type of error
The validation error code as a string. This can be used to check the type of error
Used to indicate that this field had no data supplied. This is different from having empty data, which is represented by
None. This bypasses the bit where data is set in the output dict, so the output dict will not have the associated key.