DefaultingValidator¶
- class lsst.ts.salobj.DefaultingValidator(schema: dict[str, typing.Any], StandardValidatorClass: ~typing.Type[~jsonschema.validators.Draft7Validator] = <class 'jsonschema.validators.Draft7Validator'>)¶
Bases:
object
A wrapper for jsonschema validators that applies default values.
- Parameters:
- schema
dict
Schema against which to validate.
- ValidatorClass
jsonschema.protocols.Validator
, optional jsonschema validator class, e.g.
jsonschema.Draft7Validator
.
- schema
Notes
Default values are handled at most 2 levels deep in an object hierarchy. For deeper hierarchies, set the default at a higher level. For example:
type: object properties: number1: type: number default: 1 subdict1: type: object properties: number2: type: number default: 2 subdict2: type: object properties: number3: type: number # default is ignored this deep; set it at a higher level default: number3: 3
This class is not a
jsonschema.IValidator
but it contains two validators:defaults_validator: a validator that sets default values in the data being validated
final_validator: a standard validator that does not alter the data being validated.
Methods Summary
validate
(data_dict)Validate data.
Methods Documentation