Skip to content

named method validator

thedersen edited this page Dec 26, 2011 · 3 revisions
var SomeModel = Backbone.Model.extend({
  validation: {
    name: 'validateName'
  },
  validateName: function(value) {
	if(value !== 'something') {
      return 'Name is invalid';
    }
  }
});
  • is invalid when method returns error message
  • is valid when method returns undefined
  • context is the model
Clone this wiki locally