Skip to content

Instantly share code, notes, and snippets.

@adhipg
Created March 7, 2012 11:58
Show Gist options
  • Save adhipg/1992720 to your computer and use it in GitHub Desktop.
Save adhipg/1992720 to your computer and use it in GitHub Desktop.

Just to make sure that I have all of this understood...

On the client side the code will look something like the following on the constructor:

save: =>
  errors = validator.validateMeeting(@toJSON())
  return super if not errors
  # there were errors - handle them.

Similarly, on the server side we would do something like this:

validate: function(body, callback) {
  var errors = validator.validateMeeting(body)
  if( _.isEmpty(errors) ) {
  }
  // handle errors...
}

the object that we will get back will be something like based on the errors in the model/resource:

{
  'title' : 'the title is needed.',
  'email' : 'the email address format is not valid.'
}

and, on both the places you just include the validator module to get it working?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment