Sha256: 5ce4d30595307d957ea8caea1325d35163139ec97e1813f635bec1850d9e80c0

Contents?: true

Size: 1.08 KB

Versions: 8

Compression:

Stored size: 1.08 KB

Contents

require "dry-validation"
require "pact_broker/messages"
require "pact_broker/project_root"
require "pact_broker/string_refinements"

module PactBroker
  module Api
    module Contracts
      class CanIDeployQuerySchema < BaseContract
        using PactBroker::StringRefinements

        params do
          required(:pacticipant).filled(:string)
          required(:version).filled(:string)
          optional(:to).filled(:string)
          optional(:environment).filled(:string)
        end

        rule(:pacticipant).validate(:pacticipant_with_name_exists)
        rule(:environment).validate(:environment_with_name_exists)

        rule(:to, :environment) do
          if provided?(values[:to]) && provided?(values[:environment])
            base.failure(PactBroker::Messages.message("errors.validation.cannot_specify_tag_and_environment"))
          end

          if not_provided?(values[:to]) && not_provided?(values[:environment])
            base.failure(PactBroker::Messages.message("errors.validation.must_specify_environment_or_tag"))
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
pact_broker-2.112.0 lib/pact_broker/api/contracts/can_i_deploy_query_schema.rb
pact_broker-2.111.0 lib/pact_broker/api/contracts/can_i_deploy_query_schema.rb
pact_broker-2.109.1 lib/pact_broker/api/contracts/can_i_deploy_query_schema.rb
pact_broker-2.109.0 lib/pact_broker/api/contracts/can_i_deploy_query_schema.rb
pact_broker-2.108.0 lib/pact_broker/api/contracts/can_i_deploy_query_schema.rb
pact_broker-2.107.1 lib/pact_broker/api/contracts/can_i_deploy_query_schema.rb
pact_broker-2.107.0 lib/pact_broker/api/contracts/can_i_deploy_query_schema.rb
pact_broker-2.107.0.beta.1 lib/pact_broker/api/contracts/can_i_deploy_query_schema.rb