Class: ValidateParams::Types::Boolean
- Inherits:
-
Object
- Object
- ValidateParams::Types::Boolean
- Defined in:
- lib/validate_params/types/boolean.rb
Constant Summary collapse
- TRUE_VALUES =
[true, 1, "1", :"1", "t", :t, "T", :T, "true", :true, "TRUE", :TRUE, "on", :on, "ON", :ON].to_set.freeze
- FALSE_VALUES =
[false, 0, "0", :"0", "f", :f, "F", :F, "false", :false, "FALSE", :FALSE, "off", :off, "OFF", :OFF].to_set.freeze
Class Method Summary collapse
Class Method Details
.cast(raw_value) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/validate_params/types/boolean.rb', line 13 def self.cast(raw_value, **) return true if TRUE_VALUES.include?(raw_value) return false if FALSE_VALUES.include?(raw_value) raw_value end |
.valid?(value) ⇒ Boolean
9 10 11 |
# File 'lib/validate_params/types/boolean.rb', line 9 def self.valid?(value) value.is_a?(::TrueClass) || value.is_a?(::FalseClass) end |