Skip to content

Commit 9a96193

Browse files
committed
Whoops, forgot to save. Moved validate docs into the docs.
1 parent dcec9ba commit 9a96193

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

docs/validate.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,29 @@ The simplest way to validate an instance under a given schema is to use the
1414

1515
.. function:: validate
1616

17+
Validate an ``instance`` under the given ``schema``.
18+
19+
>>> validate([2, 3, 4], {"maxItems" : 2})
20+
Traceback (most recent call last):
21+
...
22+
ValidationError: [2, 3, 4] is too long
23+
24+
:func:`validate` will first verify that the provided schema is itself
25+
valid, since not doing so can lead to less obvious error messages and fail
26+
in less obvious or consistent ways. If you know you have a valid schema
27+
already or don't care, you might prefer using the ``validate`` method
28+
directly on a specific validator (e.g. :meth:`Draft3Validator.validate`).
29+
30+
``cls`` is a validator class that will be used to validate the instance.
31+
By default this is a draft 3 validator. Any other provided positional and
32+
keyword arguments will be provided to this class when constructing a
33+
validator.
34+
35+
:raises:
36+
:exc:`ValidationError` if the instance is invalid
37+
38+
:exc:`SchemaError` if the schema itself is invalid
39+
1740

1841
The Validator Interface
1942
-----------------------

0 commit comments

Comments
 (0)