Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Includes all error definition in the API docs #407

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,31 @@ Python Error Representations
Error Codes
~~~~~~~~~~~

These errors are used as :attr:`~cerberus.errors.ValidationError.code`.
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

Expand Down
2 changes: 1 addition & 1 deletion docs/includes/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def load_module_members(name, path):
error_type = errors_module['ErrorDefinition']
error_definitions = []
for name, member in errors_module.items():
if not isinstance(member, error_type) or member.rule is None:
if not isinstance(member, error_type):
continue
error_definition = SimpleNamespace(**member._asdict())
error_definition.name = name
Expand Down