Module: ValidatesDecencyOf
- Defined in:
- lib/validates_decency_of.rb
Overview
Uses George Carlin’s list of “seven dirty words” to “check for decency” (ahem) en.wikipedia.org/wiki/Seven_dirty_words Future versions will support adding/removing from this list Ex:
class Message < ActiveRecord::Base
validates_decency_of :title, :description
end
Configuration Options
:message
-
A custom error message (default is: “is invalid”)
Defined Under Namespace
Modules: ClassMethods Classes: DecencyValidator
Constant Summary collapse
- INDECENT_WORDS =
%w(shit piss fuck cunt cocksucker motherfucker tits)
Class Method Summary collapse
Class Method Details
.indecent?(str) ⇒ Boolean
18 19 20 21 |
# File 'lib/validates_decency_of.rb', line 18 def self.indecent?(str) essence = str.to_s.downcase.gsub /[^\.\'a-zA-Z]/, '' INDECENT_WORDS.any? { |c| essence.include? c } end |