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.


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


class Foo
  include ActiveModel::Validations
  attr_accessor :foo

  validates :foo, potty_mouth: true


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.


  1. Fork it ( )
  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