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

Validation should stop at first instance of failure #217

Open
kashifshamaz21 opened this issue Mar 18, 2014 · 0 comments
Open

Validation should stop at first instance of failure #217

kashifshamaz21 opened this issue Mar 18, 2014 · 0 comments

Comments

@kashifshamaz21
Copy link

When an array of validation rules are set for an attribute, then when the validation runs on such an attribute, all validation rules/functions get examined even if one of the rules has already failed. Ideally, the validation engine should stop examining other rules once it encounters a rule that fails validation.

This is important in cases where after a set of basic client side validation, we need to do an ajax call to validate the attribute on server-side. In this case, the server call needs to happen if and only if, all the previous basic validators have passed successfully.
If any of them fail, the final ajax call should not be fired.

Example;
validation: {
username: [{
required: true,
msg: "username is required"
}, {
fn: function(value, attribute, model) {
// do ajax call to validate on server
}]
}

In the above case, when validation is fired against the username field, then even if the username is empty or null, the custom function validator (which calls the server api) still runs. If the first validator(required validator in the above case) has failed, the plugin should not execute any more validators and throw up the error message configured for that validator.

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