Sha256: 5903b8d1a334a16e0b0f5400ec9d9f2b18ba455d589daa810091c33702d9a4d1
Contents?: true
Size: 870 Bytes
Versions: 12
Compression:
Stored size: 870 Bytes
Contents
class OpenAPIParser::SchemaValidator class IntegerValidator < Base include ::OpenAPIParser::SchemaValidator::Enumable include ::OpenAPIParser::SchemaValidator::MinimumMaximum # validate integer value by schema # @param [Object] value # @param [OpenAPIParser::Schemas::Schema] schema 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?(Integer) value, err = check_enum_include(value, schema) return [nil, err] if err check_minimum_maximum(value, schema) end private def coerce(value) return value if value.kind_of?(Integer) begin Integer(value) rescue ArgumentError, TypeError value end end end end
Version data entries
12 entries across 12 versions & 2 rubygems