summaryrefslogtreecommitdiff
path: root/README.rst
diff options
context:
space:
mode:
Diffstat (limited to 'README.rst')
-rw-r--r--README.rst27
1 files changed, 27 insertions, 0 deletions
diff --git a/README.rst b/README.rst
index a6fa856..26e6a2e 100644
--- a/README.rst
+++ b/README.rst
@@ -53,6 +53,33 @@ Features
* Small and extensible
+* Programmatic querying of which properties or items failed validation.
+
+ >>> from jsonschema import ErrorTree, Validator
+ >>> schema = {
+ ... "type" : "array",
+ ... "items" : {"type" : "number", "enum" : [1, 2, 3]},
+ ... "minItems" : 3,
+ ... }
+ >>> instance = ["spam", 2]
+ >>> v = Validator()
+ >>> tree = ErrorTree(v.iter_errors(instance, schema))
+
+ >>> sorted(tree.errors)
+ ['minItems']
+
+ >>> 0 in tree
+ True
+
+ >>> 1 in tree
+ False
+
+ >>> sorted(tree[0].errors)
+ ['enum', 'type']
+
+ >>> print(tree[0].errors["type"].message)
+ 'spam' is not of type 'number'
+
Schema Versioning
-----------------