Skip to content

Instantly share code, notes, and snippets.

@nicinabox
Created November 18, 2012 22:18
Show Gist options
  • Save nicinabox/4107838 to your computer and use it in GitHub Desktop.
Save nicinabox/4107838 to your computer and use it in GitHub Desktop.
class window.Domain extends Backbone.Model
initialize: ->
@on 'error', (model, errors) ->
console.log errors
validate: (attrs) ->
errors = []
domains = _.pluck app.Domains, 'url'
if _.include(domains, attrs.url)
errors.push "URL must be unique"
if _.isEmpty attrs.url
errors.push "URL cannot be blank"
unless _.isEmpty(errors)
errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment