batmanjs/batman — pull request #1010 by rmosolgo (2014-03-22 02:24:51+00:00)
Title: Validation messages

Make Model validators take custom messages (string or function) or use specific translations.

These work:

```coffee
class MyApp.Thing extends Batman.Model
@validate 'name', presence: true, message: "You gotta choose a name!"
@validate 'color', inclusion: { in: ['red', 'blue']}, message: -> "Pick red or blue, not #{@get('color')}!"
```

Also, when looking up a message, ErrorsSet will try
```coffee
options.message
# then
"errors.messages.#{resourceName}.#{key}.#{messageSymbol}"
# then
"errors.messages.#{messageSymbol}"
```
Implementation inspired by Rails:
- [`errors.add(key, messageSymbol, options)`](https://github.com/rails/rails/blob/master/activemodel/lib/active_model/validations/length.rb#L57)
- [message normalization](https://github.com/rails/rails/blob/master/activemodel/lib/active_model/errors.rb#L439)

Inspired by #1007