Skip to content

Instantly share code, notes, and snippets.

@johnbintz
Created June 14, 2011 20:32
Show Gist options
  • Save johnbintz/1025803 to your computer and use it in GitHub Desktop.
Save johnbintz/1025803 to your computer and use it in GitHub Desktop.
Make Backbone report validation errors, much like @model.save! in Rails
class Backbone.ValidatingModel extends Backbone.Model
_performValidation: (attrs, options = {}) ->
_options = _.clone(options)
_options.error = (model, error, opts) ->
throw new Error(error)
super(attrs, _options)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment