validictory module¶
validate¶
-
validictory.
validate
(data, schema, validator_cls=<class 'validictory.validator.SchemaValidator'>, format_validators=None, required_by_default=True, blank_by_default=False, disallow_unknown_properties=False, apply_default_to_data=False, fail_fast=True, remove_unknown_properties=False)¶ Validates a parsed json document against the provided schema. If an error is found a
ValidationError
is raised.If there is an issue in the schema a
SchemaError
will be raised.Parameters: - data – python data to validate
- schema – python dictionary representing the schema (see `schema format`_)
- validator_cls – optional validator class (default is
SchemaValidator
) - format_validators – optional dictionary of custom format validators
- required_by_default – defaults to True, set to False to make
required
schema attribute False by default. - disallow_unknown_properties – defaults to False, set to True to disallow properties not listed in the schema definition
- apply_default_to_data – defaults to False, set to True to modify the data in case the schema definition includes a “default” property
- fail_fast – defaults to True, set to False if you prefer to get all validation errors back instead of only the first one
- remove_unknown_properties – defaults to False, set to True to filter out properties not listed in the schema definition. Only applies when disallow_unknown_properties is False.
SchemaValidator¶
-
class
validictory.
SchemaValidator
(format_validators=None, required_by_default=True, blank_by_default=False, disallow_unknown_properties=False, apply_default_to_data=False, fail_fast=True, remove_unknown_properties=False)¶ Validator largely based upon the JSON Schema proposal but useful for validating arbitrary python data structures.
Parameters: - format_validators – optional dictionary of custom format validators
- required_by_default – defaults to True, set to False to make
required
schema attribute False by default. - blank_by_default – defaults to False, set to True to make
blank
schema attribute True by default. - disallow_unknown_properties – defaults to False, set to True to disallow properties not listed in the schema definition
- apply_default_to_data – defaults to False, set to True to modify the data in case the schema definition includes a “default” property
- fail_fast – defaults to True, set to False if you prefer to get all validation errors back instead of only the first one
- remove_unknown_properties – defaults to False, set to True to filter out properties not listed in the schema definition. Only applies when disallow_unknown_properties is False.