Skip to content
thedersen edited this page Jan 21, 2012 · 4 revisions
var SomeModel = Backbone.Model.extend({
  validation: {
    name: function(value) {
      if(value !== 'something') {
        return 'Name is invalid';
      }
	}
  }
});

var SomeModel = Backbone.Model.extend({
  validation: {
    name: {
	  fn: 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