Skip to content
thedersen edited this page Dec 26, 2011 · 4 revisions
var SomeModel = Backbone.Model.extend({
  validation: {
    name: function(value) {
      if(value !== 'something') {
		// return an error message if the value is invalid; otherwise, return undefined
        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