Class: ValidatesDecencyOf::DecencyValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
lib/validates_decency_of.rb

Instance Method Summary collapse

Instance Method Details

#validate(record) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/validates_decency_of.rb', line 36

def validate(record)
  message = options[:message] || 'is indecent'
  attributes.each do |name|
    if ValidatesDecencyOf.indecent? record.send(name)
      record.errors.add name, message
    end
  end
end