Sha256: 371587f475ef03cac6c2e3efd4c3a7a3167011cd00d321c6c865a3f80eb1f6fd
Contents?: true
Size: 1.02 KB
Versions: 2
Compression:
Stored size: 1.02 KB
Contents
# frozen_string_literal: true require "openapi3_parser/validation/error" require "openapi3_parser/validation/error_collection" module Openapi3Parser module Validation class Validatable attr_reader :context, :errors, :factory UNDEFINED = Class.new def initialize(factory, context: nil) @factory = factory @context = context || factory.context @errors = [] end def input context.input end def add_error(error, given_context = nil, factory_class = UNDEFINED) return unless error return @errors << error if error.is_a?(Validation::Error) @errors << Validation::Error.new( error, given_context || context, factory_class == UNDEFINED ? factory.class : factory_class ) end def add_errors(errors) errors = errors.to_a if errors.respond_to?(:to_a) errors.each { |e| add_error(e) } end def collection ErrorCollection.new(errors) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
openapi3_parser-0.5.1 | lib/openapi3_parser/validation/validatable.rb |
openapi3_parser-0.5.0 | lib/openapi3_parser/validation/validatable.rb |