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

coerce is a little over zealous #7

Closed
deanlandolt opened this issue Nov 11, 2010 · 5 comments
Closed

coerce is a little over zealous #7

deanlandolt opened this issue Nov 11, 2010 · 5 comments

Comments

@deanlandolt
Copy link
Contributor

it looks like the patching of json-schema's coerce is a little over zealous -- it will coerce for required values that don't actually have keys, which causes inserts that should fail to succeed with, for instance, an empty string

@kriszyp
Copy link
Member

kriszyp commented Nov 11, 2010

So undefined shouldn't be coerced?

@deanlandolt
Copy link
Contributor Author

well, void 0 should probably, sure...but !key in object shouldn't be, if you know what i'm saying...

it forces all keys to exist (even the required ones) and creates false positives in schema validation

@deanlandolt
Copy link
Contributor Author

and shouldn't it be an opt-in? like, shouldn't you have to have a coerce: true member on your schema descriptor?

@kriszyp
Copy link
Member

kriszyp commented Nov 11, 2010

Does this fix it?
kriszyp/commonjs-utils@f9ed902

@deanlandolt
Copy link
Contributor Author

perfect...if you think it's better to coerce by default -- i guess it doesn't hurt in a postel kinda way, perhaps a "coerce" config setting would also be useful...just a thought, but this works for me

This issue was closed.
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

2 participants