Class: Sequent::Core::Helpers::BooleanValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
lib/sequent/core/helpers/boolean_validator.rb

Overview

Validates Boolean’s Automatically included when using a

attrs value: Boolean

The values:

true, false, ‘’true’‘, `’false’‘, nil, and blank?

are considered valid Booleans.

They will be converted to true, false or nil

Instance Method Summary collapse

Instance Method Details

#validate_each(subject, attribute, value) ⇒ Object



22
23
24
25
26
27
# File 'lib/sequent/core/helpers/boolean_validator.rb', line 22

def validate_each(subject, attribute, value)
  unless Sequent::Core::Helpers::ValueValidators.for(Boolean).valid_value?(value)
    subject.errors.add attribute,
                       :invalid_boolean
  end
end