Class: OpenAPIParser::SchemaValidator::AnyOfValidator

Inherits:
Base
  • Object
show all
Defined in:
lib/openapi_parser/schema_validators/any_of_validator.rb

Instance Attribute Summary

Attributes inherited from Base

#validator

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

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

Instance Method Details

#coerce_and_validate(value, schema) ⇒ Object

Parameters:



5
6
7
8
9
10
11
12
# File 'lib/openapi_parser/schema_validators/any_of_validator.rb', line 5

def coerce_and_validate(value, schema)
  # in all schema return error (=true) not any of data
  schema.any_of.each do |s|
    coerced, err = validator.validate_schema(value, s)
    return [coerced, nil] if err.nil?
  end
  [nil, OpenAPIParser::NotAnyOf.new(value, schema.object_reference)]
end