Skip to content
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

undefined fields shouldn't be used when checking enum #142

Open
wavern1 opened this issue Jun 26, 2017 · 4 comments
Open

undefined fields shouldn't be used when checking enum #142

wavern1 opened this issue Jun 26, 2017 · 4 comments

Comments

@wavern1
Copy link

wavern1 commented Jun 26, 2017

If a field is undefined and the schema specifies it as being an enum, it errors out saying "must be an enum value".

I think the logical approach here would be to skip that field unless isRequired is set to true on it as well

@LinusU
Copy link
Collaborator

LinusU commented Jul 4, 2017

Yeah, the same is true when type: ['null', 'string'], enum: ['a', 'b'], null is not accepted. Unfortunately I think that this is a part of the JSON Schema specification so I'm not sure that we could change it.

If someone could quote the spec on how this should be handled I'd be happy to fix it 👍

@RangerMauve
Copy link
Contributor

I think the main issue is that undefined isn't a valid JSON value, so the spec wouldn't have anything to say on the matter.

In my opinion, undefined should be treated the same as the key not existing, since it would disappear when the object got serialized to JSON.

@LinusU
Copy link
Collaborator

LinusU commented Jul 4, 2017

Ah, of course, that is true. Yeah, I also think that we should treat undefined as the value isn't there...

@RangerMauve
Copy link
Contributor

It'll probably make calculating minProperties and maxProperties more annoying. :P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants