summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorJulian Berman <Julian@GrayVines.com>2013-02-03 01:03:26 -0500
committerJulian Berman <Julian@GrayVines.com>2013-02-03 01:03:26 -0500
commit7bcbf984d58914ce406599c416ee1f611803f331 (patch)
tree7e08ec63ba8e28ae60170aaf38abceb8f9d7ecec /docs
parent2282e971da34fa0c797e9505d3d6a6ac0698a64b (diff)
downloadjsonschema-7bcbf984d58914ce406599c416ee1f611803f331.tar.gz
Checkers docs and sample usage
Diffstat (limited to 'docs')
-rw-r--r--docs/validate.rst18
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