class OpenAPIParser::SchemaValidator::BooleanValidator
Constants
- FALSE_VALUES
- TRUE_VALUES
Public Instance Methods
coerce_and_validate(value, schema, **_keyword_args)
click to toggle source
# File lib/openapi_parser/schema_validators/boolean_validator.rb, line 8 def coerce_and_validate(value, schema, **_keyword_args) value = coerce(value) if @coerce_value return OpenAPIParser::ValidateError.build_error_result(value, schema) unless value.kind_of?(TrueClass) || value.kind_of?(FalseClass) value, err = check_enum_include(value, schema) return [nil, err] if err [value, nil] end
Private Instance Methods
coerce(value)
click to toggle source
# File lib/openapi_parser/schema_validators/boolean_validator.rb, line 21 def coerce(value) return true if TRUE_VALUES.include?(value) return false if FALSE_VALUES.include?(value) value end