Class: PactBroker::Api::Contracts::BaseContract

Inherits:
Dry::Validation::Contract
  • Object
show all
Extended by:
DryValidationErrorsFormatter
Includes:
DryValidationMethods
Defined in:
lib/pact_broker/api/contracts/base_contract.rb

Class Method Summary collapse

Methods included from DryValidationErrorsFormatter

add_error, add_indexed_error, format_errors

Methods included from DryValidationMethods

#not_provided?, #provided?, #validate_environment_with_name_exists, #validate_no_spaces_if_present, #validate_not_blank_if_present, #validate_not_multiple_lines, #validate_pacticipant_with_name_exists, #validate_url, #validate_valid_url, #validate_version_number, #validation_message

Class Method Details

.call(params) ⇒ Hash

The entry method for all the Dry::Validation::Contract classes eg. MyContract.call(params) It takes the params (doesn’t matter if they’re string or symbol keys) executes the dry-validation validation, and formats the errors into the Pactflow format.

Parameters:

  • the (Hash)

    parameters to validate

Returns:

  • (Hash)

    the validation errors to display to the user



24
25
26
27
# File 'lib/pact_broker/api/contracts/base_contract.rb', line 24

def self.call(params)
  params_to_validate = params.respond_to?(:symbolize_keys) ? params.symbolize_keys : params
  new.call(params_to_validate)
end