Class: PactBroker::Api::Contracts::WebhookContract

Inherits:
BaseContract
  • Object
show all
Defined in:
lib/pact_broker/api/contracts/webhook_contract.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.errorsObject

rubocop: disable Lint/NestedMethodDefinition



24
# File 'lib/pact_broker/api/contracts/webhook_contract.rb', line 24

def self.errors; @first_errors end

Instance Method Details

#validateObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/pact_broker/api/contracts/webhook_contract.rb', line 12

def validate(*)
  result = super
  # I just cannot seem to get the validation to stop on the first error.
  # If one rule fails, they all come back failed, and it's driving me nuts.
  # Why on earth would I want that behaviour?
  # I cannot believe I have to do this shit.
  @first_errors = errors
  @first_errors.messages.keys.each do | key |
    @first_errors.messages[key] = @first_errors.messages[key][0...1]
  end

  # rubocop: disable Lint/NestedMethodDefinition
  def self.errors; @first_errors end
  # rubocop: enable Lint/NestedMethodDefinition

  result
end