File: creating.rst

package info (click to toggle)
python-jsonschema 4.25.1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 4,952 kB
  • sloc: python: 8,469; makefile: 210; sh: 12
file content (36 lines) | stat: -rw-r--r-- 1,011 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
.. currentmodule:: jsonschema.validators

.. _creating-validators:

=======================================
Creating or Extending Validator Classes
=======================================

.. autofunction:: create
    :noindex:

.. autofunction:: extend
    :noindex:

.. autofunction:: validator_for
    :noindex:

.. autofunction:: validates
    :noindex:


Creating Validation Errors
--------------------------

Any validating function that validates against a subschema should call
``descend``, rather than ``iter_errors``. If it recurses into the
instance, or schema, it should pass one or both of the ``path`` or
``schema_path`` arguments to ``descend`` in order to properly maintain
where in the instance or schema respectively the error occurred.

The Validator Protocol
----------------------

``jsonschema`` defines a `protocol <typing.Protocol>`, `jsonschema.protocols.Validator` which can be used in type annotations to describe the type of a validator.

For full details, see `validator-protocol`.