Reputation: 721
I have one backbone model that includes validation object with list of validation parameters.
var SignUpModel = Backbone.Model.extend({
validation: {
firstname: {
required: true,
pattern: 'name'
},
lastname: {
required: true,
pattern: 'name'
}
},
addToValidation: function(){
// HOW TO DO THIS???
this.validation.PUSH{
country: {
required: true
},
phone: {
required: true,
pattern: 'phone'
}
}
}
});
How to add to this object another object? I didn't find it in JS, but maybe this function exists in Backbone or Underscore?
Also maybe backbone has special thing for data keeping?
Upvotes: 1
Views: 71
Reputation: 6206
_.extend(this.validation, {
country : {
required: true
},
phone: {
required: true,
pattern: 'phone'
}
});
Upvotes: 2