File tree 1 file changed +10
-1
lines changed
1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -47,9 +47,18 @@ started:
47
47
DefaultValidatingDraft4Validator = extend_with_default(Draft4Validator)
48
48
49
49
50
+ # Example usage:
51
+ obj = {}
52
+ schema = {' properties' : {' foo' : {' default' : ' bar' }}}
53
+ # Note jsonschem.validate(obj, schema, cls=DefaultValidatingDraft4Validator)
54
+ # will not work because the metaschema contains `default` directives.
55
+ DefaultValidatingDraft4Validator(schema).validate(obj)
56
+ assert obj == {' foo' : ' bar' }
57
+
58
+
50
59
See the above-linked document for more info on how this works, but basically,
51
60
it just extends the :validator: `properties ` validator on a
52
- :class: `Draft4Validator ` to then go ahed and update all the defaults.
61
+ :class: `Draft4Validator ` to then go ahead and update all the defaults.
53
62
54
63
If you're interested in a more interesting solution to a larger class of these
55
64
types of transformations, keep an eye on `Seep
You can’t perform that action at this time.
0 commit comments