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

shims/validatejs.js - mandatory can.Map attributes with undefined value are not validated #6

Open
fantanamihai opened this issue Feb 6, 2017 · 0 comments

Comments

@fantanamihai
Copy link

Undefined attributes within a can.Map, that have a corresponding define.validate object, are not validated with validatejs.
The cause is that the validate method in shims/validatejs.js receives as first parameter can.Map.prototype.serialize(), which by default doesn't serialize undefined values. Then it filters the attributes with Object.keys(), thus fails to validate attributes with corresponding define.validate object, but no value e.g.
can.Map.extend('Test',{ define: { a: { validate: { required: true } }} }

new Test().validate() returns true

A workaround is all attributes to have a default value of 'null'. But is it desirable?

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

1 participant