Class: OpenAPIParser::SchemaValidator::IntegerValidator

Inherits:
Base
  • Object
show all
Includes:
Enumable, MinimumMaximum
Defined in:
lib/openapi_parser/schema_validator/integer_validator.rb

Instance Attribute Summary

Attributes inherited from Base

#validatable

Instance Method Summary collapse

Methods included from MinimumMaximum

#check_minimum_maximum

Methods included from Enumable

#check_enum_include

Methods inherited from Base

#initialize, #validate_discriminator_schema

Constructor Details

This class inherits a constructor from OpenAPIParser::SchemaValidator::Base

Instance Method Details

#coerce_and_validate(value, schema, **_keyword_args) ⇒ Object

validate integer value by schema

Parameters:



9
10
11
12
13
14
15
16
17
18
# File 'lib/openapi_parser/schema_validator/integer_validator.rb', line 9

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