class Attribool::Validators::StrictBooleanValidator
Ensures that a value is a boolean, unless strictness isnβt enforced.
Public Class Methods
Source
# File lib/attribool/validators/strict_boolean_validator.rb, line 13 def initialize(value, strict) @value = value @strict = strict end
Construct the validator.
@param [Object] value
@param [Boolean] strict
Public Instance Methods
Source
# File lib/attribool/validators/strict_boolean_validator.rb, line 30 def error ArgumentError.new("#{@value} is not a boolean") end
The exception to raise if validations fail.
@return [ArgumentError] the exception with message
Source
# File lib/attribool/validators/strict_boolean_validator.rb, line 22 def valid? !@strict || [TrueClass, FalseClass].include?(@value.class) end
Is strict set to false, or is +@value+ a boolean?
@return [Boolean]