Skip to content

Commit

Permalink
Pass model to valid/invalid callbacks thedersen#312
Browse files Browse the repository at this point in the history
  • Loading branch information
Luiz Américo committed Apr 21, 2018
1 parent bb8f469 commit a256ef6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/backbone-validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,11 @@ Backbone.Validation = (function(_){
_.each(attrs, _.bind(function (attr) {
error = validateAttr(this, attr, flattened[attr], _.extend({}, this.attributes));
if (error) {
options.invalid(view, attr, error, options.selector);
options.invalid(view, attr, error, options.selector, this);
invalidAttrs = invalidAttrs || {};
invalidAttrs[attr] = error;
} else {
options.valid(view, attr, options.selector);
options.valid(view, attr, options.selector, this);
}
}, this));
}, this));
Expand Down Expand Up @@ -287,10 +287,10 @@ Backbone.Validation = (function(_){
changed = changedAttrs.hasOwnProperty(attr);

if(!invalid){
opt.valid(view, attr, opt.selector);
opt.valid(view, attr, opt.selector, model);
}
if(invalid && (changed || validateAll)){
opt.invalid(view, attr, result.invalidAttrs[attr], opt.selector);
opt.invalid(view, attr, result.invalidAttrs[attr], opt.selector, model);
}
});
});
Expand Down

0 comments on commit a256ef6

Please sign in to comment.