-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
I think it would be usefull to get child errors when a collection is invalid and you call the validate method with deep option enabled.
I think this code solve this. if you think it's usefull you may use it / modify it / do what ever you want :D
@backbone-schema.js:1457
/**
* Validates the collections models
* @param {Object=} options
* @return {Array} Returns an empty array or an array of errors
* @private
*/
_validateModels: function(options) {
var errors = [];
options = options || {};
if (options.expandErrors) {
_.each(this.models, function(model) {
errors.push.apply(errors,model.validate(undefined,options));
});
} else {
if(_.any(this.models, function(model) {
return !model.isValid(undefined, options);
})) {
errors.push({
level: 'error',
rule: 'relation',
message: '%(title) is invalid',
values: {
'title': this.schema.title
}
});
}
}
return errors;
}Metadata
Metadata
Assignees
Labels
No labels