ValidatesPottyMouth Build Status Code Climate Code Coverage

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

  1. Fork it ( https://github.com/avvo/validates_potty_mouth/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request