@@ -23,31 +23,28 @@ The simplest way to validate an instance under a given schema is to use the
23
23
The Validator Interface
24
24
-----------------------
25
25
26
- :mod: `jsonschema ` defines an (informal) interface that all validators should
27
- adhere to.
26
+ :mod: `jsonschema ` defines an (informal) interface that all validator
27
+ classes should adhere to.
28
28
29
29
.. class :: IValidator(schema, types=(), resolver=None, format_checker=None)
30
30
31
- :argument dict schema: the schema that the validator will validate with. It
32
- is assumed to be valid, and providing an invalid
33
- schema can lead to undefined behavior. See
34
- :meth: `IValidator.check_schema ` to validate a schema
35
- first.
36
- :argument types: Override or extend the list of known types when validating
37
- the :validator: `type ` property. Should map strings (type
38
- names) to class objects that will be checked via
39
- :func: `isinstance `. See :ref: `validating-types ` for
40
- details.
31
+ :argument dict schema: the schema that the validator object
32
+ will validate with. It is assumed to be valid, and providing
33
+ an invalid schema can lead to undefined behavior. See
34
+ :meth: `IValidator.check_schema ` to validate a schema first.
35
+ :argument types: Override or extend the list of known types when
36
+ validating the :validator: `type ` property. Should map strings (type
37
+ names) to class objects that will be checked via :func: `isinstance `.
38
+ See :ref: `validating-types ` for details.
41
39
:type types: dict or iterable of 2-tuples
42
- :argument resolver: an instance of :class: `RefResolver ` that will be used
43
- to resolve :validator: `$ref ` properties (JSON
44
- references). If unprovided, one will be created.
45
- :argument format_checker: an instance of :class: `FormatChecker ` whose
46
- :meth: `~conforms ` method will be called to check
47
- and see if instances conform to each
48
- :validator: `format ` property present in the
49
- schema. If unprovided, no validation will be done
50
- for :validator: `format `.
40
+ :argument resolver: an instance of :class: `RefResolver ` that will be
41
+ used to resolve :validator: `$ref ` properties (JSON references). If
42
+ unprovided, one will be created.
43
+ :argument format_checker: an instance of :class: `FormatChecker `
44
+ whose :meth: `~conforms ` method will be called to check and see if
45
+ instances conform to each :validator: `format ` property present
46
+ in the schema. If unprovided, no validation will be done for
47
+ :validator: `format `.
51
48
52
49
.. attribute :: DEFAULT_TYPES
53
50
@@ -61,13 +58,13 @@ adhere to.
61
58
62
59
.. attribute :: VALIDATORS
63
60
64
- A mapping of validators (:class: `str `\s ) to functions that validate the
65
- validator property with that name. For more information see
66
- :ref: `creating-validators `.
61
+ A mapping of validator names (:class: `str `\s ) to functions
62
+ that validate the validator property with that name. For more
63
+ information see :ref: `creating-validators `.
67
64
68
65
.. attribute :: schema
69
66
70
- The schema that was passed in when initializing the validator .
67
+ The schema that was passed in when initializing the object .
71
68
72
69
73
70
.. classmethod :: check_schema(schema)
@@ -124,10 +121,11 @@ adhere to.
124
121
ValidationError: [2, 3, 4] is too long
125
122
126
123
127
- All of the :ref: `versioned validators <versioned-validators >` that are included
128
- with :mod: `jsonschema ` adhere to the interface, and implementors of validators
129
- that extend or complement the ones included should adhere to it as well. For
130
- more information see :ref: `creating-validators `.
124
+ All of the :ref: `versioned validators <versioned-validators >` that
125
+ are included with :mod: `jsonschema ` adhere to the interface, and
126
+ implementors of validator classes that extend or complement the
127
+ ones included should adhere to it as well. For more information see
128
+ :ref: `creating-validators `.
131
129
132
130
133
131
.. _validating-types :
@@ -154,7 +152,7 @@ more general instance checks can introduce significant slowdown, especially
154
152
given how common validating these types are.
155
153
156
154
If you *do * want the generality, or just want to add a few specific additional
157
- types as being acceptible for a validator, :class: `IValidator `\s have a
155
+ types as being acceptible for a validator object , :class: `IValidator `\s have a
158
156
``types `` argument that can be used to provide additional or new types.
159
157
160
158
.. code-block :: python
@@ -168,20 +166,20 @@ types as being acceptible for a validator, :class:`IValidator`\s have a
168
166
)
169
167
170
168
The list of default Python types for each JSON type is available on each
171
- validator in the :attr: `IValidator.DEFAULT_TYPES ` attribute. Note that you
172
- need to specify all types to match if you override one of the existing JSON
173
- types, so you may want to access the set of default types when specifying your
174
- additional type.
169
+ validator object in the :attr: `IValidator.DEFAULT_TYPES ` attribute. Note
170
+ that you need to specify all types to match if you override one of the
171
+ existing JSON types, so you may want to access the set of default types
172
+ when specifying your additional type.
175
173
176
174
.. _versioned-validators :
177
175
178
176
Versioned Validators
179
177
--------------------
180
178
181
- :mod: `jsonschema ` ships with validators for various versions of the JSON Schema
182
- specification. For details on the methods and attributes that each validator
183
- provides see the :class: `IValidator ` interface, which each validator
184
- implements.
179
+ :mod: `jsonschema ` ships with validator classes for various versions of
180
+ the JSON Schema specification. For details on the methods and attributes
181
+ that each validator class provides see the :class: `IValidator ` interface,
182
+ which each included validator class implements.
185
183
186
184
.. autoclass :: Draft3Validator
187
185
0 commit comments