<commit_before>.. _creating-validators:

================================
Creating or Extending Validators
================================

.. currentmodule:: jsonschema

.. autoclass:: ValidatorMixin

.. autofunction:: validates


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

Any validating function that recurses into an instance (e.g. ``properties`` or
``items``) must call ``appendleft`` on the :exc:`ValidationError.path`
attribute of the error in order to properly maintain where in the instance the
error occurred.<commit_msg>Update docs for descend method<commit_after>.. _creating-validators:

================================
Creating or Extending Validators
================================

.. currentmodule:: jsonschema

.. autoclass:: ValidatorMixin

.. autofunction:: validates


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

Any validating function that validates against a subschema should call
:meth:`ValidatorMixin.descend`, rather than :meth:`ValidatorMixin.iter_errors`.
If it recurses into the instance, or schema, it must set the ``path`` or
``schema_path`` in order to properly maintain where in the instance and schema
the error occurred.
{'fraction_non_alphanumeric': 0.22231614539306846, 'fraction_numerical': 0.0, 'mean_word_length': 4.5327102803738315, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '869640', 'n_tokens_mistral': 291, 'n_tokens_neox': 275, 'n_words': 110}