Sha256: 8ea0e1054abed168d3c395857953689f176891f3e6f0f21ecb99165138206f08

Contents?: true

Size: 662 Bytes

Versions: 23

Compression:

Stored size: 662 Bytes

Contents

class OpenAPIParser::SchemaValidator
  class OneOfValidator < Base
    # @param [Object] value
    # @param [OpenAPIParser::Schemas::Schema] schema
    def coerce_and_validate(value, schema, **_keyword_args)
      if schema.discriminator
        return validate_discriminator_schema(schema.discriminator, value)
      end

      # if multiple schemas are satisfied, it's not valid
      result = schema.one_of.one? do |s|
        _coerced, err = validatable.validate_schema(value, s)
        err.nil?
      end
      if result
        [value, nil]
      else
        [nil, OpenAPIParser::NotOneOf.new(value, schema.object_reference)]
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 2 rubygems

Version Path
openapi_parser_firetail-1.0.0 lib/openapi_parser/schema_validator/one_of_validator.rb
openapi_parser-1.0.0 lib/openapi_parser/schema_validators/one_of_validator.rb
openapi_parser-1.0.0.beta1 lib/openapi_parser/schema_validators/one_of_validator.rb
openapi_parser-0.15.0 lib/openapi_parser/schema_validators/one_of_validator.rb
openapi_parser-0.14.1 lib/openapi_parser/schema_validators/one_of_validator.rb
openapi_parser-0.14.0 lib/openapi_parser/schema_validators/one_of_validator.rb
openapi_parser-0.13.0 lib/openapi_parser/schema_validators/one_of_validator.rb
openapi_parser-0.12.1 lib/openapi_parser/schema_validators/one_of_validator.rb
openapi_parser-0.12.0 lib/openapi_parser/schema_validators/one_of_validator.rb
openapi_parser-0.11.2 lib/openapi_parser/schema_validators/one_of_validator.rb
openapi_parser-0.11.1 lib/openapi_parser/schema_validators/one_of_validator.rb
openapi_parser-0.11.0 lib/openapi_parser/schema_validators/one_of_validator.rb
openapi_parser-0.10.0 lib/openapi_parser/schema_validators/one_of_validator.rb
openapi_parser-0.9.0 lib/openapi_parser/schema_validators/one_of_validator.rb
openapi_parser-0.8.0 lib/openapi_parser/schema_validators/one_of_validator.rb
openapi_parser-0.7.0 lib/openapi_parser/schema_validators/one_of_validator.rb
openapi_parser-0.6.1 lib/openapi_parser/schema_validators/one_of_validator.rb
openapi_parser-0.6.0 lib/openapi_parser/schema_validators/one_of_validator.rb
openapi_parser-0.5.0 lib/openapi_parser/schema_validators/one_of_validator.rb
openapi_parser-0.4.1 lib/openapi_parser/schema_validators/one_of_validator.rb