MCPcopy Create free account
hub / github.com/python-jsonschema/jsonschema / iter_errors

Method iter_errors

jsonschema/protocols.py:170–189  ·  view source on GitHub ↗

r""" Lazily yield each of the validation errors in the given instance. >>> schema = { ... "type" : "array", ... "items" : {"enum" : [1, 2, 3]}, ... "maxItems" : 2, ... } >>> v = Draft202012Validator(schema) >>> for error in

(self, instance: Any)

Source from the content-addressed store, hash-verified

168 """
169
170 def iter_errors(self, instance: Any) -> Iterable[ValidationError]:
171 r"""
172 Lazily yield each of the validation errors in the given instance.
173
174 >>> schema = {
175 ... "type" : "array",
176 ... "items" : {"enum" : [1, 2, 3]},
177 ... "maxItems" : 2,
178 ... }
179 >>> v = Draft202012Validator(schema)
180 >>> for error in sorted(v.iter_errors([2, 3, 4]), key=str):
181 ... print(error.message)
182 4 is not one of [1, 2, 3]
183 [2, 3, 4] is too long
184
185 .. deprecated:: v4.0.0
186
187 Calling this function with a second schema argument is deprecated.
188 Use `Validator.evolve` instead.
189 """
190
191 def validate(self, instance: Any) -> None:
192 """

Calls

no outgoing calls