Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions dist/backbone-validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,11 @@ Backbone.Validation = (function(_){
_.each(attrs, 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 @@ -298,10 +298,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 Expand Up @@ -429,7 +429,7 @@ Backbone.Validation = (function(_){
// Gets called when a previously invalid field in the
// view becomes valid. Removes any error message.
// Should be overridden with custom functionality.
valid: function(view, attr, selector) {
valid: function(view, attr, selector, model) {
view.$('[' + selector + '~="' + attr + '"]')
.removeClass('invalid')
.removeAttr('data-error');
Expand All @@ -438,7 +438,7 @@ Backbone.Validation = (function(_){
// Gets called when a field in the view becomes invalid.
// Adds a error message.
// Should be overridden with custom functionality.
invalid: function(view, attr, error, selector) {
invalid: function(view, attr, error, selector, model) {
view.$('[' + selector + '~="' + attr + '"]')
.addClass('invalid')
.attr('data-error', error);
Expand Down Expand Up @@ -706,4 +706,4 @@ Backbone.Validation = (function(_){
});

return Validation;
}(_));
}(_));