Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Knockout Validation ko.validation.group vs ko.validatedObservable

What is the difference in ko.validation.group and ko.validatedObservable? Are there particular situations when I should use one over the other?

like image 760
Homer Avatar asked Oct 24 '12 20:10

Homer


1 Answers

The ko.validation.group just gives you an (computed) observable of all the error messages in a model. It only collects error messages of direct properties of the model.

The ko.validatedObservable on the other hand not only collects the error messages, but also wraps the model in an observable and adds an isValid property which indicates whether or not there are any error messages (i.e., the model was completely valid). Otherwise, they're essentially the same.

If you're only interested in collecting the error messages, the ko.validation.group should be more than enough. If you need an observable that keeps track of whether or not the model is valid, the ko.validatedObservable does some of the work for you.

like image 79
Jeff Mercado Avatar answered Oct 22 '22 05:10

Jeff Mercado