Class: ActiveModel::Validations::TruthinessValidator

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

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



4
5
6
# File 'lib/validates_truthiness.rb', line 4

def validate_each(record, attribute, value)
  record.errors[attribute] << "must be either True or False" unless (value.is_a?(FalseClass) || value.is_a?(TrueClass))
end