You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this case, only the "dog" field is missing but there is no field on the error that tells me that without taking apart the message (which I don't want to do as the message is more likely to change that a separate field).
validator_value lists both fields so that isn't useful.
Comparing the validator_value items to keys in instance may work, but that gets complex if there are 3 or more required fields:
import jsonschema
schema = {
"type": "object",
"properties": {
"cat": {
"type": "string"
},
"dog": {
"type": "string"
},
"ferret": {
"type": "string"
}
},
"required": ["cat","dog", "ferret"]
}
data = {
"cat": "socks"
}
validator = jsonschema.Draft7Validator(schema)
for e in validator.iter_errors(data):
print("ERROR")
for k,v in e.__dict__.items():
print(k + " = " + str(v))
Hi, this is #119 -- which essentially is going to be solved by doing #119 (comment) -- a small PR to get that started likely is indeed welcome, though it's also on my own TODO list after I finish working on the $ref implementation.
Certainly if you care to give it a shot though it's welcome in small chunks! Otherwise keep an eye on that issue.
Uh oh!
There was an error while loading. Please reload this page.
Consider:
The output is:
In this case, only the "dog" field is missing but there is no field on the error that tells me that without taking apart the message (which I don't want to do as the message is more likely to change that a separate field).
validator_value lists both fields so that isn't useful.
Comparing the validator_value items to keys in instance may work, but that gets complex if there are 3 or more required fields:
Gives:
Could we have a new field added to this error to just state what is missing? (in the first example - "dog")
Happy to have a go if you think this is a good idea.
Thank you!
The text was updated successfully, but these errors were encountered: