thedersen/backbone.validation — Issue #21: No invalid attributes returned when a model is invalid
Author: andyuk
Created: 2012-02-08 12:00:09+00:00
State: open

Hi,

I've had a couple issues when I don't know why my model isn't validating. The invalid attributes array returns empty, even though something is invalid. This is because the attribute wasn't set.

For example:

mymodel.set({}); // name is required, but it's missing!
mymodel.model.bind('validated', function(valid, model, attr){
refute(valid);
assert.equals([], attr);
});

Yet, if I set the attribute, I will get the invalid attribute back.

mymodel.set({name: null}); // name is defined, but null.
mymodel.model.bind('validated', function(valid, model, attr){
refute(valid);
assert.equals(['name'], attr);
});

Hope my code makes sense. Is there a good reason for why it is working the way it is?

-- Andy