Skip to content

Commit

Permalink
Fixed issue where validations tripped on a non-exinstant property on the
Browse files Browse the repository at this point in the history
map when specifically testing for errors on that property name.
  • Loading branch information
gsmeets committed Nov 10, 2014
1 parent 7aa6456 commit 398f2df
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions map/validations/validations.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,11 @@ steal('can/util', 'can/map', function (can) {
errors[attr].push(res);
}
});
}, validations = this.constructor.validations,
}, validations = this.constructor.validations || {},
isTest = attrs && attrs.length === 1 && arguments.length === 2;
// go through each attribute or validation and
// add any errors
can.each(attrs || validations || {}, function (funcs, attr) {
can.each(attrs || validations, function (funcs, attr) {
// if we are iterating through an array, use funcs
// as the attr name
if (typeof attr === 'number') {
Expand Down
4 changes: 4 additions & 0 deletions map/validations/validations_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,4 +343,8 @@ steal("can/map/validations", "can/compute", "can/test", function () {
task.attr('age', 'bad');
task.attr('age', 'still bad');
});
test('Validate undefined property', function () {
new can.Map().errors( "foo" );
ok(true, "does not throw" );
});
});

0 comments on commit 398f2df

Please sign in to comment.