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

Remote Validation Rules and group.validationErrors().length #380

Closed
mariusfilipowski opened this issue Dec 11, 2013 · 2 comments
Closed

Comments

@mariusfilipowski
Copy link

I really like the support of async rules via ajax.
I am facing now a problem, when I use them.

I have a custom submit-button on my page that should only work, when all validation rules are met (validationErrors().length === 0). This works perfectly with normal rules.
But when I have a remote rules with multiple fields, that at first are correct but when I've entered invalid input, the remote validation starts.
In the meantime - for some seconds - I am able to trigger my submit button since the remote validation rules are still running and no validation errors are in that array.

What is the best way to solve this?
My idea: It would be nice when the validationGroup would also provide a check for the isValidating()-Observable of all containing observables.

Thanks for helping...

@dnutels
Copy link

dnutels commented Jul 1, 2014

Have this been resolved?

This seems like a bug, as from the usage standpoint, validation should provide the same features, whether there are some fields that are validated asynchronously or not.

In the current paradigm there is a isValidating observable that would serve the same purpose for group validation as it does for single field. There is no such property currently on the ViewModel that is being validate using:

ko.validation.group(viewModel);

Thoughts?

@crissdev
Copy link
Member

crissdev commented Feb 5, 2015

The grouping feature now gives access to validatables through some Array methods #449. This means you can write things like:

var result = ko.validation.group({ /*properties*/ });

var isValidating = !!result.find(function(observable) {
    return !!ko.unwrap(observable.isValidating);
});

@crissdev crissdev closed this as completed Feb 5, 2015
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

3 participants