Class: Openapi3Parser::Validators::MutuallyExclusiveFields

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

Defined Under Namespace

Classes: MutuallyExclusiveFieldErrors

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.call(*args, **kwargs) ⇒ Object



11
12
13
# File 'lib/openapi3_parser/validators/mutually_exclusive_fields.rb', line 11

def self.call(*args, **kwargs)
  new.call(*args, **kwargs)
end

Instance Method Details

#call(validatable, mutually_exclusive_fields:, raise_on_invalid: true) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/openapi3_parser/validators/mutually_exclusive_fields.rb', line 15

def call(validatable,
         mutually_exclusive_fields:,
         raise_on_invalid: true)
  mutually_exclusive = MutuallyExclusiveFieldErrors.new(
    mutually_exclusive_fields, validatable.input
  )

  handle_required_errors(validatable,
                         mutually_exclusive.required_errors,
                         raise_on_invalid)
  handle_exclusive_errors(validatable,
                          mutually_exclusive.exclusive_errors,
                          raise_on_invalid)
end