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



20
21
22
# File 'lib/sequent/core/helpers/boolean_validator.rb', line 20

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