Class: HashValidator::Validator::BooleanValidator

Inherits:
Base
  • Object
show all
Defined in:
lib/hash_validator/validators/boolean_validator.rb

Instance Attribute Summary

Attributes inherited from Base

#name

Instance Method Summary collapse

Methods inherited from Base

#error_message, #should_validate?, #validate

Constructor Details

#initializeBooleanValidator

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

#valid?(value) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/hash_validator/validators/boolean_validator.rb', line 6

def valid?(value)
  [TrueClass, FalseClass].include?(value.class)
end