Class: Openapi3Parser::Validators::MutuallyExclusiveFields::MutuallyExclusiveFieldErrors

Inherits:
Object
  • Object
show all
Defined in:
lib/openapi3_parser/validators/mutually_exclusive_fields.rb

Instance Method Summary collapse

Constructor Details

#initialize(mutually_exclusive_fields, input) ⇒ MutuallyExclusiveFieldErrors

Returns a new instance of MutuallyExclusiveFieldErrors.


66
67
68
69
# File 'lib/openapi3_parser/validators/mutually_exclusive_fields.rb', line 66

def initialize(mutually_exclusive_fields, input)
  @mutually_exclusive_fields = mutually_exclusive_fields
  @input = input
end

Instance Method Details

#errorsObject


79
80
81
82
83
84
85
86
87
# File 'lib/openapi3_parser/validators/mutually_exclusive_fields.rb', line 79

def errors
  @errors ||= begin
    default = { required: [], exclusive: [] }
    mutually_exclusive_fields
      .each_with_object(default) do |exclusive, errors|
        add_error(errors, exclusive)
      end
  end
end

#exclusive_errorsObject


75
76
77
# File 'lib/openapi3_parser/validators/mutually_exclusive_fields.rb', line 75

def exclusive_errors
  errors[:exclusive]
end

#required_errorsObject


71
72
73
# File 'lib/openapi3_parser/validators/mutually_exclusive_fields.rb', line 71

def required_errors
  errors[:required]
end