Skip to content

Commit

Permalink
Allow preValidate to work with dependent properties
Browse files Browse the repository at this point in the history
  • Loading branch information
Cameron Crothers committed Jul 29, 2014
1 parent 08d01da commit f095b48
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/backbone-validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,18 @@ Backbone.Validation = (function(_){
error;

if(_.isObject(attr)){
_.each(attr, function(value, key) {
var oldAttr = this.attributes;
_.extend(this.attributes, attr);

_.each(attr, function(value, key) {
error = self.preValidate(key, value);
if(error){
result[key] = error;
}
});

this.attributes = oldAttr;

return _.isEmpty(result) ? undefined : result;
}
else {
Expand Down

0 comments on commit f095b48

Please sign in to comment.