ValidatesPottyMouth
Validate against blacklist of words
Originally idea conceived by bvandenbos. ActiveModel::Validator to prevent bad words in your data.
Installation
Add this line to your application's Gemfile:
gem 'validates_potty_mouth'
And then execute:
$ bundle
Or install it yourself as:
$ gem install validates_potty_mouth
Usage
class Foo
include ActiveModel::Validations
attr_accessor :foo
validates :foo, potty_mouth: true
end
Configuration
You can set the word list message as configuration for the validator. The default list is named :default
.
validates :foo, potty_mouth: {list: :mylist, message: 'cannot be so shouty.'}
To add a word list:
PottyMouthValidator.add_list(:my_list, '/path/to_file')
The file should have one word per line.
Contributing
- Fork it ( https://github.com/avvo/validates_potty_mouth/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request