File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,29 @@ The simplest way to validate an instance under a given schema is to use the
14
14
15
15
.. function :: validate
16
16
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
+
17
40
18
41
The Validator Interface
19
42
-----------------------
You can’t perform that action at this time.
0 commit comments