Skip to content

Instantly share code, notes, and snippets.

$ brunch b --production
Validator.errors
'in': 'The :attribute must be one of the following types: :values'
'between': 'The :attribute must be between :value1 - :value2'
# Single error
Validator.error 'is_batman', 'The :attribute must be batman'
# Bunch of errors
Validator.errors
'is_batman': 'The :attribute must be batman'
'email': 'The :attribute must be a valid email'
Validator.rule 'is_batman', (attribute, value, params) ->
if value is 'batman'
return true
return false
Validation.attributes
user_name: 'username'
validation.make({user_name: ''}, {user_name: 'required'})
# Will return "The user_name is required"
validation.errors.first('user_name')
validation.errors.has('city')
validation.errors.all()
validation.errors.get('password')
validation.errors.first('name')