validate: function(attrs, options) {
errors = {};
+ foundErrors = false;
_.each(this.validators, function(validatorList, fieldName) {
_.each(validatorList, function(validator) {
if (fieldName in attrs) {
validatorResult = validateField(validator, attrs[fieldName])
if (validatorResult != true) {
errors[fieldName] = validatorResult;
+ foundErrors = true;
}
}
});
});
- return errors;
+ if (foundErrors) {
+ return errors;
+ }
+ // backbone.js semantics -- on successful validate, return nothing
}
});
var that = this;\r
var isNew = !this.model.id;\r
\r
+ this.$el.find(".help-inline").remove();\r
+\r
/* although model.validate() is called automatically by\r
model.save, we call it ourselves, so we can throw up our\r
validation error before creating the infoMsg in the log\r
},\r
\r
onFormDataInvalid: function(errors) {\r
- this.$el.find(".help-inline").remove();\r
var self=this;\r
var markErrors = function(value, key) {\r
console.log("name='" + key + "'");\r