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

Form.Editor.validate() reads all form values for nothing #518

Open
sniederb opened this issue Jun 22, 2016 · 2 comments
Open

Form.Editor.validate() reads all form values for nothing #518

sniederb opened this issue Jun 22, 2016 · 2 comments

Comments

@sniederb
Copy link

Backbone.Form.Editor.validate() has the lines ...

var formValues = this.form ? this.form.getValue() : {},
...
error = getValidator(validator)(value, formValues);

However, all validators only have the signature
function(value)

As form validation calls editor.validate() for each editor, and then each editor build the entire form value model, the superfluous this.form.getValue() creates O(n^2) calls for nothing.

@fonji
Copy link
Contributor

fonji commented Jun 22, 2016

I actually use formValues in my custom validators...
A solution would be to pass the editor to the validator, then the validator can call editor.form.getValue() if necessary.
It would also offer access to the editor's config, which might be useful.

@sniederb
Copy link
Author

fonji, I really like that idea. Would be great to see that change soon.

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