-
-
Notifications
You must be signed in to change notification settings - Fork 308
Regarding uniqueItems error interpretation #1099
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@gregsdennis would you handle this as one entry in the error structure, and any information about how many / what kind of problems would go into the detail string? Or multiple error entries, one for each way in which it could fail? What do you do for |
In my implementation I generate one error (all the validation vocabulary keywords generate just one error), and an indication of where in the data the error lies. For example, the data
(edited data instance to add more duplicate items, to make it clear that even with longer arrays only one error is generated) |
I think a single output unit would suffice here. It's the keyword that failed to validate, so it makes sense to only include a single unit for the keyword. Bearing that in mind, #973 is considering adding an instance-based structure (instead of a schema-based structure) as a possible output format. If this is used, it may make sense to include each violation. This hasn't been hashed out yet though. |
Yes, I was not precise enough. I was assuming one validation error, the question was about the need to identify the individual errors in verbose or detailed outputs. Luckily, both questions were solved :) I see that @karenetheridge's implementation adopts the third option, which is consistent with the definition of an array as an indexed set and also probably the most robust approach. I am going to close this issue and subscribe to #973 to be aware of upcoming changes. Thank you all for this answer and for all the others, this repo has become my JSON-Schema Bible ;) |
JSON Schema specs define an array as an ordered sequence of zero or more values and its instance equality as both are arrays and have an equal value item-for-item but, AFAIK, do not state which mathematical object corresponds to this type and therefore neither its concept of multiplicity.
So, for instance, in a
uniqueItems
validation against[1, 1, 2, 2, 2, 3]
, how many errors should we say have occurred?1
and2
are not unique.1
, the second2
, and the third2
are repeated elements.{1, 1, 2, 2, 2}
.The text was updated successfully, but these errors were encountered: