Skip to content

Validation should stop at first instance of failure #217

Open
@kashifshamaz21

Description

@kashifshamaz21

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions