Description
So, following up on #396, one thing I'd also love to see discussed or addressed is what my implementation calls best_match
.
The purpose of this function is to heuristically answer the question "given a schema and instance with multiple issues, what is the most fundamentally wrong with the instance?".
An example to illustrate:
- having the wrong type is a pretty big deal, and usually indicates that something is very very wrong with the instance
- having everything correct but being slightly too short or long is way less fundamentally wrong with the instance
So if you imagine an instance with both issues, we'd select the first error over the second one.
So, question: how well defined is this notion, and can we standardize an algorithm here?
Here's my implementation (which by the way is not promised to return the same values over time, in case I come up with a better implementation, but that hasn't happened yet):
https://github.com/Julian/jsonschema/blob/master/jsonschema/exceptions.py#L274-L278
You'll find that this touches quickly on a notion of "descent" into anyOf
/ oneOf
/ allOf
sub-errors, which I find pretty interesting to think about too, but I'll refrain from elaborating on that until someone else confirms this is interesting to discuss.
Metadata
Metadata
Assignees
Type
Projects
Status