Sha256: fe3b138e4abc653025c5fdb7726ee7b4225c0689a76d1f24c4dbc87fe28b490e

Contents?: true

Size: 1.04 KB

Versions: 5

Compression:

Stored size: 1.04 KB

Contents

require 'dry-validation'
require 'pact_broker/api/contracts/dry_validation_workarounds'
require 'pact_broker/api/contracts/dry_validation_predicates'

module PactBroker
  module Api
    module Contracts
      class VerifiablePactsQuerySchema
        extend DryValidationWorkarounds
        using PactBroker::HashRefinements

        SCHEMA = Dry::Validation.Schema do
          configure do
            predicates(DryValidationPredicates)
          end
          optional(:provider_version_tags).maybe(:array?)
          optional(:consumer_version_selectors).each do
            schema do
              required(:tag).filled(:str?)
              required(:latest).filled(included_in?: ["true"])
            end
          end
          optional(:include_pending_status).filled(included_in?: ["true", "false"])
          optional(:include_wip_pacts_since).filled(:date?)
        end

        def self.call(params)
          select_first_message(flatten_indexed_messages(SCHEMA.call(params&.symbolize_keys).messages(full: true)))
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pact_broker-2.45.0 lib/pact_broker/api/contracts/verifiable_pacts_query_schema.rb
pact_broker-2.44.0 lib/pact_broker/api/contracts/verifiable_pacts_query_schema.rb
pact_broker-2.43.0 lib/pact_broker/api/contracts/verifiable_pacts_query_schema.rb
pact_broker-2.42.0 lib/pact_broker/api/contracts/verifiable_pacts_query_schema.rb
pact_broker-2.41.0 lib/pact_broker/api/contracts/verifiable_pacts_query_schema.rb