-
Notifications
You must be signed in to change notification settings - Fork 280
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
enum
shouldn't override other values, right?
#87
Comments
Hello @toddobryan , thank you for reporting it. You are right, |
But shouldn't |
I can't see any reason for that. It is unnecessary for your specific case, and shouldn't work that way in generic cases (since enum values can be any values, not only strings). |
See the first link above. According to the spec, you can attach This could be useful in weird cases. For example, imagine this schema:
representing things that can be recognized as booleans. The schema:
would limit someone to the In any case, according to the spec, it's perfectly valid to combine http://json-schema.org/latest/json-schema-validation.html#rfc.section.4.1 Are you interested in handling all valid schemas according to the spec, or just ones that make sense? |
@toddobryan I understand your point. It is a quite generic design flaw of the library that the inheritance hierarchy of I'm not sure how serious problem it is. The official test suite doesn't contain such "mixed" examples (neither for draft 4 nor for draft 6). So the |
One more sidenote: you are referring to sections of the latest version of the specification (which is unofficially called draft-6), while this library is the implementation of draft-4 (draft-4 core and draft-4 validation ). This is somewhat misleading, you can read a bit more on this wiki page. Draft-6 was released in April. A new version of this library supporting draft-6 is on the way, i'm working on it, but there is no ETA. |
Hello @toddobryan , I released the new version yesterday. Links: |
According to the last example on this page
https://spacetelescope.github.io/understanding-json-schema/reference/generic.html#enumerated-values
it's possible to have a
type
in addition to anenum
. And, in fact, you should be able to add theenum
constraint to basically any schema. (At least, I think that's what the spec says.)http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.23
and
http://json-schema.org/latest/json-schema-validation.html#rfc.section.4.4
However, when I run this code:
I get this:
From the Spec, it doesn't look like
"enum"
is even allowed as a value fortype
.http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.25
I'd like to fix this, but want to make sure people agree it's wrong before I do.
The text was updated successfully, but these errors were encountered: