Skip to content

Instantly share code, notes, and snippets.

@joshmcarthur
Last active December 19, 2015 01:09
Show Gist options
  • Save joshmcarthur/5873626 to your computer and use it in GitHub Desktop.
Save joshmcarthur/5873626 to your computer and use it in GitHub Desktop.
Validate the length (in words) of a string
# Short introduction may be blank, but may not be longer than 250 words
validates :short_introduction, length: {maximum: 250, tokenizer: -> (str) { str.scan(/\w+/) } }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment