Sha256: 1359189f454503d5d6c312dc1f2ec2876e0e810172e4414764a8b49bf3270d63
Contents?: true
Size: 863 Bytes
Versions: 11
Compression:
Stored size: 863 Bytes
Contents
class OpenAPIParser::SchemaValidator class FloatValidator < Base include ::OpenAPIParser::SchemaValidator::Enumable # validate float value by schema # @param [Object] value # @param [OpenAPIParser::Schemas::Schema] schema def coerce_and_validate(value, schema) value = coerce(value) if @coerce_value return validatable.validate_integer(value, schema) if value.kind_of?(Integer) coercer_and_validate_numeric(value, schema) end private def coercer_and_validate_numeric(value, schema) return OpenAPIParser::ValidateError.build_error_result(value, schema) unless value.kind_of?(Numeric) check_enum_include(value, schema) end def coerce(value) Float(value) rescue ArgumentError => e raise e unless e.message =~ /invalid value for Float/ end end end
Version data entries
11 entries across 11 versions & 1 rubygems