Sha256: 246a4671636bc64aa0ba8b9d2af2bad4b6fe06dac9c4e132aa2eefa5a518734b

Contents?: true

Size: 1.23 KB

Versions: 36

Compression:

Stored size: 1.23 KB

Contents

require "dry-validation"
require "pact_broker/api/contracts/dry_validation_workarounds"
require "pact_broker/api/contracts/dry_validation_predicates"
require "pact_broker/messages"

module PactBroker
  module Api
    module Contracts
      class PacticipantSchema
        extend DryValidationWorkarounds
        extend PactBroker::Messages
        using PactBroker::HashRefinements

        SCHEMA = Dry::Validation.Schema do
          configure do
            predicates(DryValidationPredicates)
            config.messages_file = File.expand_path("../../../locale/en.yml", __FILE__)
          end
          optional(:name).filled(:str?, :single_line?)
          optional(:displayName).maybe(:str?, :single_line?, :not_blank?)
          optional(:mainBranch).maybe(:str?, :single_line?, :no_spaces?)
          optional(:repositoryUrl).maybe(:str?, :single_line?)
          optional(:repositoryName).maybe(:str?, :single_line?)
          optional(:repositoryNamespace).maybe(:str?, :single_line?)
        end

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

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
pact_broker-2.106.0 lib/pact_broker/api/contracts/pacticipant_schema.rb
pact_broker-2.105.0 lib/pact_broker/api/contracts/pacticipant_schema.rb
pact_broker-2.104.0 lib/pact_broker/api/contracts/pacticipant_schema.rb
pact_broker-2.103.0 lib/pact_broker/api/contracts/pacticipant_schema.rb
pact_broker-2.102.2 lib/pact_broker/api/contracts/pacticipant_schema.rb
pact_broker-2.102.1 lib/pact_broker/api/contracts/pacticipant_schema.rb
pact_broker-2.102.0 lib/pact_broker/api/contracts/pacticipant_schema.rb
pact_broker-2.101.0 lib/pact_broker/api/contracts/pacticipant_schema.rb
pact_broker-2.100.0 lib/pact_broker/api/contracts/pacticipant_schema.rb
pact_broker-2.99.0 lib/pact_broker/api/contracts/pacticipant_schema.rb
pact_broker-2.98.0 lib/pact_broker/api/contracts/pacticipant_schema.rb
pact_broker-2.97.0 lib/pact_broker/api/contracts/pacticipant_schema.rb
pact_broker-2.96.0 lib/pact_broker/api/contracts/pacticipant_schema.rb
pact_broker-2.95.1 lib/pact_broker/api/contracts/pacticipant_schema.rb
pact_broker-2.95.0 lib/pact_broker/api/contracts/pacticipant_schema.rb
pact_broker-2.94.0 lib/pact_broker/api/contracts/pacticipant_schema.rb
pact_broker-2.93.4 lib/pact_broker/api/contracts/pacticipant_schema.rb
pact_broker-2.93.3 lib/pact_broker/api/contracts/pacticipant_schema.rb
pact_broker-2.93.2 lib/pact_broker/api/contracts/pacticipant_schema.rb
pact_broker-2.93.1 lib/pact_broker/api/contracts/pacticipant_schema.rb