Sha256: 7c860d39fe43fb570fb879f9893d60faed7a3cc2dc7e110ec1edd1fb857d3d11

Contents?: true

Size: 1.06 KB

Versions: 9

Compression:

Stored size: 1.06 KB

Contents

require 'reform'
require 'reform/form'
require 'uri'

module PactBroker
  module Api
    module Contracts
      class VerificationContract < Reform::Form

        property :success
        property :provider_version, as: :providerApplicationVersion
        property :build_url, as: :buildUrl

        validation do
          configure do
            config.messages_file = File.expand_path("../../../locale/en.yml", __FILE__)

            def not_blank? value
              value && value.to_s.strip.size > 0
            end

            def valid_url? url
              URI(url)
            rescue URI::InvalidURIError, ArgumentError
              nil
            end

            def valid_version_number?(value)
              parsed_version_number = PactBroker.configuration.version_parser.call(value)
              !!parsed_version_number
            end
          end

          required(:success).filled(:bool?)
          required(:provider_version) { not_blank? & valid_version_number? }
          optional(:build_url).maybe(:valid_url?)
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
pact_broker-2.30.0 lib/pact_broker/api/contracts/verification_contract.rb
pact_broker-2.29.0 lib/pact_broker/api/contracts/verification_contract.rb
pact_broker-2.27.6 lib/pact_broker/api/contracts/verification_contract.rb
pact_broker-2.27.5 lib/pact_broker/api/contracts/verification_contract.rb
pact_broker-2.27.4 lib/pact_broker/api/contracts/verification_contract.rb
pact_broker-2.27.3 lib/pact_broker/api/contracts/verification_contract.rb
pact_broker-2.27.2 lib/pact_broker/api/contracts/verification_contract.rb
pact_broker-2.27.0 lib/pact_broker/api/contracts/verification_contract.rb
pact_broker-2.26.1 lib/pact_broker/api/contracts/verification_contract.rb