1.7 KiB
		
	
	
	
	
	
	
	
			
		
		
	
	Creating or Extending Validators
jsonschema.validators
create
Create a new validator.
- argument dict meta_schema
 - 
the meta schema for the new validator
 - argument dict validators
 - 
a mapping from validator names to functions that validate the given name. Each function should take 4 arguments: a validator instance, the value of the current validator property in the instance being validated, the instance, and the schema.
 - argument str version
 - 
an identifier for the version that this validator will validate. If provided, the returned validator class will have its
__name__set to include the version, and also will havevalidatesautomatically called for the given version. - argument dict default_types
 - 
a default mapping to use for instances of the validator when mapping between JSON types to Python types. The default for this argument is probably fine. Instances of the returned validator can still have their types customized on a per-instance basis.
 - returns
 - 
an
jsonschema.IValidator 
validates
Creating Validation Errors
Any validating function that validates against a subschema should
call ValidatorMixin.descend, rather than ValidatorMixin.iter_errors.
If it recurses into the instance, or schema, it should pass one or both
of the path or schema_path arguments to ValidatorMixin.descend in
order to properly maintain where in the instance or schema respsectively
the error occurred.