Closed JBurning closed 1 month ago
This is expected behavior from a library. It is up to the caller how to decide how to display the messages. The messages should already contain sufficient context on the error, for instance you can get the value that caused the failure from the instanceNode
or the relevant schema from schemaNode
. You may find OutputFormat.HIERARCHICAL
more helpful in visualising the error. You may also consider using if
, then
, else
in your schema if you have a heuristic for determining which of the anyOf
should likely match given your data.
Thankfully my schema allowed me to resolve this using if
then
else
statements to guide the validation. Thanks for the clarification.
I found a new case where the error messages are far less helpful than what other programs can do. Here I am using anyOf to match for objects with different types of properties in a list. When I purposely use an incorrect type on one of my objects in my yaml, VSCode this shows the following very succinct error:
But when I run this through this library, the message I'm hit with is this:
Which is just giving me all of the possible errors in all the schemas and then some instead of trying to match the object to the closest possible schema and then validating it using that alone. Is there a way around this or does this just need to get fixed?
Schema:
Sample: