File: api.rst

package info (click to toggle)
python-cerberus 1.3.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,532 kB
  • sloc: python: 5,239; makefile: 130
file content (120 lines) | stat: -rw-r--r-- 3,146 bytes parent folder | download
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
API Documentation
=================

Validator Class
---------------

.. autoclass:: cerberus.Validator
  :members: allow_unknown, clear_caches, document, document_error_tree,
            document_path, _drop_remaining_rules, _error, error_handler,
            _errors, errors, _get_child_validator, ignore_none_values,
            is_child, _lookup_field, mandatory_validations, normalized,
            priority_validations, purge_unknown, recent_error,
            require_all, _remaining_rules, root_allow_unknown, root_document,
            root_require_all, root_schema, rules_set_registry, schema,
            schema_error_tree, schema_path, schema_registry, types,
            types_mapping, _valid_schemas, validate, validated


Rules Set & Schema Registry
---------------------------

.. autoclass:: cerberus.schema.Registry
  :members:


Type Definitions
----------------

.. autoclass:: cerberus.TypeDefinition


Error Handlers
--------------

.. autoclass:: cerberus.errors.BaseErrorHandler
  :members:
  :private-members:
  :special-members:

.. autoclass:: cerberus.errors.BasicErrorHandler


Python Error Representations
----------------------------

.. autoclass:: cerberus.errors.ErrorDefinition

.. autoclass:: cerberus.errors.ValidationError
  :members:

.. _error-codes:

Error Codes
~~~~~~~~~~~

Its :attr:`code` attribute uniquely identifies an
:class:`~cerberus.errors.ErrorDefinition` that is used a concrete error's
:attr:`~cerberus.errors.ValidationError.code`.
Some codes are actually reserved to mark a shared property of different errors.
These are useful as bitmasks while processing errors. This is the list of the
reserved codes:

============= ======== === ===================================================
``0110 0000`` ``0x60``  96 An error that occurred during normalization.
``1000 0000`` ``0x80`` 128 An error that contains child errors.
``1001 0000`` ``0x90`` 144 An error that was emitted by one of the \*of-rules.
============= ======== === ===================================================

None of these bits in the upper nibble must be used to enumerate error
definitions, but only to mark one with the associated property.

.. important::

    Users are advised to set bit 8 for self-defined errors. So the code
    ``0001 0000 0001`` / ``0x101`` would the first in a domain-specific set of
    error definitions.


This is a list of all error defintions that are shipped with the
:mod:`~cerberus.errors` module:

.. include:: includes/error-codes.rst

Error Containers
~~~~~~~~~~~~~~~~

.. autoclass:: cerberus.errors.ErrorList

.. autoclass:: cerberus.errors.ErrorTree
  :members:

.. autoclass:: cerberus.errors.DocumentErrorTree

.. autoclass:: cerberus.errors.SchemaErrorTree


Exceptions
----------

.. autoexception:: cerberus.SchemaError

.. autoexception:: cerberus.DocumentError


Utilities
---------

.. automodule:: cerberus.utils
  :members:


.. _schema-validation-schema:

Schema Validation Schema
------------------------

Against this schema validation schemas given to a vanilla
:class:`~cerberus.Validator` will be validated:

.. include:: includes/schema-validation-schema.rst