-
Notifications
You must be signed in to change notification settings - Fork 300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
isNew and changed attrs #130
Comments
I am seeing this as well. It comes down to this check here: https://github.com/thedersen/backbone.validation/blob/master/dist/backbone-validation-amd.js#L263 I am going to have to figure out a workaround and report back. |
I decided to just hack this part out:
|
Hi, we also encounter problems with this peace of code In our case it seems to be the same problem as issue #220. We need a fix for this, is it possible to apply @cmwelsh's fix ( |
Tried to apply @cmwelsh's but unit test fails, so its not a good fix. In our case the problem is encountered when we validate a model where attributes are not defined. var ModelClass = Backbone.Model.extend({
validation : {
name : {
required : true
}
}
});
...
var model = new ModelClass();
if(model.save() === false) {
// We should enter here but the _intersection instruction prevent it
} As a workaround we simply define default values in our model classes. var ModelClass = Backbone.Model.extend({
defaults : {
name : undefined
},
validation : {
name : {
required : true
}
}
})
...
var model = new ModelClass();
if(model.save() === false) {
// Now we should enter here
} Hope this helps. |
@bgaillard Your fix is good when your attributes aren't dynamic. Anyway, this is a known-issue and we're working on it. Also reported by #188. |
Hi @chiefGui, I didn't remember I posted this :-) Happy to see the library is regularly updated now, we use it in several projects and it helps us a lot, thanks. |
Hey @bgaillard! I'm glad to know that you use it in your projects. Lots of things are about to come — stay in sync! 😄 |
What about changing the line |
@chk- Feel free to write up a pull request if you think that approach will work! |
Hi
When the validation is running on a new model with unchanged attributes the validation isnt applied correctly.
When I debug
validate
i can see all correct errors in result.invalidAttrs but because changedAttrs is empty because the model is brand new and not changed the validation slips through and the model is saved to the server anywayBackbone 1.0
The text was updated successfully, but these errors were encountered: