Sha256: 49c5cfe9cd8dee700fa623ab13389251f43afce2a498d171bd966c3010f1f265

Contents?: true

Size: 1.42 KB

Versions: 15

Compression:

Stored size: 1.42 KB

Contents

require 'reform'
require 'reform/contract'
require 'pact_broker/messages'
require 'pact_broker/constants'
require 'pact_broker/api/contracts/pacticipant_name_contract'
require 'pact_broker/api/contracts/consumer_version_number_validation'

module PactBroker
  module Api
    module Contracts

      class PutPacticipantNameContract < PacticipantNameContract

        validates :name, presence: true, blank: false
        validate :name_in_path_matches_name_in_pact

        def name_in_path_matches_name_in_pact
          if present?(name) && present?(name_in_pact)
            if name != name_in_pact
              errors.add(:name, validation_message('pacticipant_name_mismatch', message_args))
            end
          end
        end

        def present? string
          string && !blank?(string)
        end

      end

      class PutPactParamsContract < Reform::Contract

        include PactBroker::Messages

        property :consumer_version_number
        property :consumer, form: PutPacticipantNameContract
        property :provider, form: PutPacticipantNameContract

        validates :consumer_version_number, presence: true
        validate :consumer_version_number_valid


        include ConsumerVersionNumberValidation

        def consumer_version_number_validation_message
          validation_message('consumer_version_number_invalid', consumer_version_number: consumer_version_number)
        end

      end


    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
pact_broker-1.14.0 lib/pact_broker/api/contracts/put_pact_params_contract.rb
pact_broker-1.13.0 lib/pact_broker/api/contracts/put_pact_params_contract.rb
pact_broker-1.12.0 lib/pact_broker/api/contracts/put_pact_params_contract.rb
pact_broker-1.11.2 lib/pact_broker/api/contracts/put_pact_params_contract.rb
pact_broker-1.11.1 lib/pact_broker/api/contracts/put_pact_params_contract.rb
pact_broker-1.11.0 lib/pact_broker/api/contracts/put_pact_params_contract.rb
pact_broker-1.10.0 lib/pact_broker/api/contracts/put_pact_params_contract.rb
pact_broker-1.9.3 lib/pact_broker/api/contracts/put_pact_params_contract.rb
pact_broker-1.9.2 lib/pact_broker/api/contracts/put_pact_params_contract.rb
pact_broker-1.9.1 lib/pact_broker/api/contracts/put_pact_params_contract.rb
pact_broker-1.9.0 lib/pact_broker/api/contracts/put_pact_params_contract.rb
pact_broker-1.9.0.rc1 lib/pact_broker/api/contracts/put_pact_params_contract.rb
pact_broker-1.8.1 lib/pact_broker/api/contracts/put_pact_params_contract.rb
pact_broker-1.8.0 lib/pact_broker/api/contracts/put_pact_params_contract.rb
pact_broker-1.7.0 lib/pact_broker/api/contracts/put_pact_params_contract.rb