diff options
author | Julian Berman <Julian@GrayVines.com> | 2013-02-03 01:03:26 -0500 |
---|---|---|
committer | Julian Berman <Julian@GrayVines.com> | 2013-02-03 01:03:26 -0500 |
commit | 7bcbf984d58914ce406599c416ee1f611803f331 (patch) | |
tree | 7e08ec63ba8e28ae60170aaf38abceb8f9d7ecec /docs/validate.rst | |
parent | 2282e971da34fa0c797e9505d3d6a6ac0698a64b (diff) | |
download | jsonschema-7bcbf984d58914ce406599c416ee1f611803f331.tar.gz |
Checkers docs and sample usage
Diffstat (limited to 'docs/validate.rst')
-rw-r--r-- | docs/validate.rst | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/docs/validate.rst b/docs/validate.rst index 902293c..0d38cdc 100644 --- a/docs/validate.rst +++ b/docs/validate.rst @@ -171,7 +171,25 @@ primitive types (``str``\s, ``number``\s, ``bool``\s) conform to well-defined formats. By default, no validation is enforced, but optionally, validation can be enabled by hooking in a format-checking object into an :class:`IValidator`. +.. doctest:: + + >>> validate("tomorrow", {"format" : "date"}) + >>> validate( + ... "tomorrow", {"format" : "date"}, format_checker=FormatChecker(), + ... ) + Traceback (most recent call last): + ... + ValidationError: "tomorrow" is not a "date" + + .. autoclass:: FormatChecker :members: + .. attribute:: checkers + + A mapping of currently known formats to functions that validate them. + New checkers can be added and removed either per-instance or globally + for all checkers using the :meth:`FormatChecker.checks` or + :meth:`FormatChecker.cls_checks` decorators respectively. + .. autofunction:: is_date_time |