Class: HashValidator::Validator::BooleanValidator
- Defined in:
- lib/hash_validator/validators/boolean_validator.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize ⇒ BooleanValidator
constructor
A new instance of BooleanValidator.
- #validate(key, value, _validations, errors) ⇒ Object
Methods inherited from Base
#presence_error_message, #should_validate?
Constructor Details
#initialize ⇒ BooleanValidator
Returns a new instance of BooleanValidator.
2 3 4 |
# File 'lib/hash_validator/validators/boolean_validator.rb', line 2 def initialize super('boolean') # The name of the validator end |
Instance Method Details
#validate(key, value, _validations, errors) ⇒ Object
6 7 8 9 10 |
# File 'lib/hash_validator/validators/boolean_validator.rb', line 6 def validate(key, value, _validations, errors) unless [TrueClass, FalseClass].include?(value.class) errors[key] = end end |