@@ -36,29 +36,29 @@ raised or returned, depending on which method or function is used.
36
36
37
37
.. attribute:: validator
38
38
39
- The name of the failed `validator
39
+ The name of the failed `keyword
40
40
<https://json-schema.org/draft/2020-12/json-schema-validation.html#name-a-vocabulary-for-structural> `_.
41
41
42
42
.. attribute:: validator_value
43
43
44
- The value for the failed validator in the schema.
44
+ The associated value for the failed keyword in the schema.
45
45
46
46
.. attribute:: schema
47
47
48
48
The full schema that this error came from. This is potentially a
49
49
subschema from within the schema that was passed in originally,
50
- or even an entirely different schema if a :validator : `$ref ` was
50
+ or even an entirely different schema if a :kw : `$ref ` was
51
51
followed.
52
52
53
53
.. attribute:: relative_schema_path
54
54
55
- A `collections.deque ` containing the path to the failed
56
- validator within the schema.
55
+ A `collections.deque ` containing the path to the failed keyword
56
+ within the schema.
57
57
58
58
.. attribute:: absolute_schema_path
59
59
60
60
A `collections.deque ` containing the path to the failed
61
- validator within the schema, but always relative to the
61
+ keyword within the schema, but always relative to the
62
62
*original * schema as opposed to any subschema (i.e. the one
63
63
originally passed into a validator class, *not * `schema `\) .
64
64
@@ -179,7 +179,7 @@ the specific part of the instance and subschema that caused each of the errors.
179
179
This can be seen with the `ValidationError.instance ` and
180
180
`ValidationError.schema ` attributes.
181
181
182
- With validators like :validator : `anyOf `, the `ValidationError.context `
182
+ With keywords like :kw : `anyOf `, the `ValidationError.context `
183
183
attribute can be used to see the sub-errors which caused the failure. Since
184
184
these errors actually came from two separate subschemas, it can be helpful to
185
185
look at the `ValidationError.schema_path ` attribute as well to see where
@@ -224,8 +224,8 @@ easier debugging.
224
224
ErrorTrees
225
225
----------
226
226
227
- If you want to programmatically be able to query which properties or validators
228
- failed when validating a given instance, you probably will want to do so using
227
+ If you want to programmatically query which validation keywords
228
+ failed when validating a given instance, you may want to do so using
229
229
`jsonschema.exceptions.ErrorTree ` objects.
230
230
231
231
.. autoclass:: jsonschema.exceptions.ErrorTree
@@ -235,7 +235,7 @@ failed when validating a given instance, you probably will want to do so using
235
235
236
236
.. attribute:: errors
237
237
238
- The mapping of validator names to the error objects (usually
238
+ The mapping of validator keywords to the error objects (usually
239
239
`jsonschema.exceptions.ValidationError `\s ) at this level
240
240
of the tree.
241
241
@@ -301,18 +301,17 @@ the `ErrorTree.errors` attribute.
301
301
>>> sorted(tree[0].errors)
302
302
['enum', 'type']
303
303
304
- Here we see that the :validator: `enum ` and :validator: `type ` validators failed
305
- for index ``0 ``. In fact `ErrorTree.errors ` is a dict, whose values are
306
- the `ValidationError `\s , so we can get at those directly if we want
307
- them.
304
+ Here we see that the :kw: `enum ` and :kw: `type ` keywords failed for
305
+ index ``0 ``. In fact `ErrorTree.errors ` is a dict, whose values are the
306
+ `ValidationError `\s , so we can get at those directly if we want them.
308
307
309
308
.. doctest::
310
309
311
310
>>> print(tree[0].errors["type"].message)
312
311
'spam' is not of type 'number'
313
312
314
- Of course this means that if we want to know if a given named
315
- validator failed for a given index, we check for its presence in
313
+ Of course this means that if we want to know if a given validation
314
+ keyword failed for a given index, we check for its presence in
316
315
`ErrorTree.errors `:
317
316
318
317
.. doctest::
@@ -323,9 +322,9 @@ validator failed for a given index, we check for its presence in
323
322
>>> "minimum" in tree[0].errors
324
323
False
325
324
326
- Finally, if you were paying close enough attention, you'll notice that we
327
- haven't seen our :validator : `minItems ` error appear anywhere yet. This is
328
- because :validator : `minItems ` is an error that applies globally to the instance
325
+ Finally, if you were paying close enough attention, you'll notice that
326
+ we haven't seen our :kw : `minItems ` error appear anywhere yet. This is
327
+ because :kw : `minItems ` is an error that applies globally to the instance
329
328
itself. So it appears in the root node of the tree.
330
329
331
330
.. doctest::
@@ -336,9 +335,9 @@ itself. So it appears in the root node of the tree.
336
335
That's all you need to know to use error trees.
337
336
338
337
To summarize, each tree contains child trees that can be accessed by
339
- indexing the tree to get the corresponding child tree for a given index
340
- into the instance. Each tree and child has a `ErrorTree.errors `
341
- attribute, a dict, that maps the failed validator name to the
338
+ indexing the tree to get the corresponding child tree for a given
339
+ index into the instance. Each tree and child has a `ErrorTree.errors `
340
+ attribute, a dict, that maps the failed validation keyword to the
342
341
corresponding validation error.
343
342
344
343
@@ -373,14 +372,14 @@ to guess the most relevant error in a given bunch.
373
372
`sorted ` or `max ` will cause more relevant errors to be
374
373
considered greater than less relevant ones.
375
374
376
- Within the different validators that can fail, this function
377
- considers :validator : `anyOf ` and :validator : `oneOf ` to be *weak *
378
- validation errors, and will sort them lower than other validators at
379
- the same level in the instance.
375
+ Within the different validation keywords that can fail, this
376
+ function considers :kw : `anyOf ` and :kw : `oneOf ` to be *weak *
377
+ validation errors, and will sort them lower than other errors at the
378
+ same level in the instance.
380
379
381
- If you want to change the set of weak [or strong] validators you can create
382
- a custom version of this function with ` by_relevance ` and provide a
383
- different set of each.
380
+ If you want to change the set of weak [or strong] validation
381
+ keywords you can create a custom version of this function with
382
+ ` by_relevance ` and provide a different set of each.
384
383
385
384
.. doctest::
386
385
0 commit comments