thedersen/backbone.validation — Issue #27: equalTo weird behavior
Author: hyusetiawan
Created: 2012-02-26 00:37:42+00:00
State: open

I am using Backbone 0.9.1 and as you are aware, there is a change the way models validate. As stated in the What gets validated when? part of the README the data needs to exist in the model before it can get validated, how should I use equalTo then? Because as I serialize the form and call validate on it, I use this.model.set(raw_json_of_form) but password is not set yet at that time.

My temporary hack/fix is to change equalTo to:

equalTo: function(value, attr, equalTo, child, model) {
if(value !== model[equalTo]) {
return format(messages.equalTo, attr, equalTo);
}
},