rails/rails — pull request #16381 by kakipo (2014-08-03 06:09:16+00:00)
Title: Allow symbol as values for `tokenize` of `LengthValidator`

This commit allows to specify a method name for `tokenize` of `LengthValidator`.

```
class Article
include ActiveModel::Model

validates_length_of :content,
:minimum => 10,
:message => "must be at least 10 words",
:tokenizer => :tokenize_by_words

def tokenize_by_words(text)
text.scan(/\w+/)
end
end
```

This makes the code easy to read, and is useful when the same tokenizer is used across the models.

Although it could be provided as a custom validator, I would love to have this function in core ActiveModel. Please let me know what you think.