Closed hicksjduk closed 4 years ago
@hicksjduk Can you suggest a better message? Maybe something like
Instance does not match any of the schemas, exactly one is required
The existing message is fine, but that wasn't what I was talking about. What I said was that the messages from the validation of the subschemas should also be included.
@hicksjduk How well does the "nestedErrors" option work for you?
What is the "nestedErrors" option? Where is it documented? How is it used?
@hasansaghir It's described in a (somewhat short) passage in the README. You set it to true, and the output will include the errors will produced within. They are normally suppressed because it would also be an error to fix all of them.
How about you play around with it, see what the output looks like, and let me know how you think the README.md can be improved.
The nestedErrors option does exactly what I want, thanks.
The main thing that is missing from the README is how to set the option: I had to look in the code to find out. It would also be good to have something which lists all the supported options. And thenestedErrors option should be referenced from the examples which show how to use anyOf, allOf or oneOf.
I'll spin that into a paragraph and add an example then.
Added an example and rewrote some of the text in 320464812ed401500dcae231b13c998f32dbe957. Please let me know how you think that works.
Thanks Austin, that looks great. Thank you for your help with this.
This might be already covered by another issue, but I can't tell from the descriptions.
When I specify that a property is oneOf two nested schemas (referenced by $ref), if it doesn't match either schema then the validation fails correctly, but the only message issues says that it doesn't match exactly one of the schemas. This is correct, but to be helpful the errors raised when validating the nested schemas should also be included.
See https://github.com/hicksjduk/jsonschema for a test case showing this.