Backbone.js offers validation for models. But there is no a simple way to check all models in collection are valid. No .isValid
property for collections.
I use a hack like this:
_.isEmpty(_.filter(myCollection.models, function(m) {return m.validationError;}))
Is there more optimized way to 'validate' collection?
What about using some method?
var hasErrors = _.some(myCollection.models, function(m) {
return m.validationError;
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With