Sha256: d1a5b75fe7753efb7c03991b1c86dae222083f165ac9af9f8042d7d5ee6c1bb9

Contents?: true

Size: 1.04 KB

Versions: 41

Compression:

Stored size: 1.04 KB

Contents

require 'reform'
require 'reform/form'

module PactBroker
  module Api
    module Contracts
      class WebhookContract < Reform::Form
        property :request

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

          required(:request).filled
        end

        property :request do
          property :url
          property :http_method

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

              def valid_method?(value)
                Net::HTTP.const_defined?(value.capitalize)
              end

              def valid_url?(value)
                uri = URI(value)
                uri.scheme && uri.host
              rescue URI::InvalidURIError
                false
              end
            end

            required(:http_method).filled(:valid_method?)
            required(:url).filled(:valid_url?)
          end
        end
      end
    end
  end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
pact_broker-2.12.0 lib/pact_broker/api/contracts/webhook_contract.rb
pact_broker-2.11.0 lib/pact_broker/api/contracts/webhook_contract.rb
pact_broker-2.10.0 lib/pact_broker/api/contracts/webhook_contract.rb
pact_broker-2.9.0 lib/pact_broker/api/contracts/webhook_contract.rb
pact_broker-2.9.0.beta.5 lib/pact_broker/api/contracts/webhook_contract.rb
pact_broker-2.8.0.beta.5 lib/pact_broker/api/contracts/webhook_contract.rb
pact_broker-2.8.0.beta.4 lib/pact_broker/api/contracts/webhook_contract.rb
pact_broker-2.7.0.beta.3 lib/pact_broker/api/contracts/webhook_contract.rb
pact_broker-2.7.0.beta.2 lib/pact_broker/api/contracts/webhook_contract.rb
pact_broker-2.7.0.beta.1 lib/pact_broker/api/contracts/webhook_contract.rb
pact_broker-2.6.0 lib/pact_broker/api/contracts/webhook_contract.rb
pact_broker-2.5.1 lib/pact_broker/api/contracts/webhook_contract.rb
pact_broker-2.5.0 lib/pact_broker/api/contracts/webhook_contract.rb
pact_broker-2.4.2 lib/pact_broker/api/contracts/webhook_contract.rb
pact_broker-2.4.1 lib/pact_broker/api/contracts/webhook_contract.rb
pact_broker-2.4.0 lib/pact_broker/api/contracts/webhook_contract.rb
pact_broker-2.3.0 lib/pact_broker/api/contracts/webhook_contract.rb
pact_broker-2.2.0 lib/pact_broker/api/contracts/webhook_contract.rb
pact_broker-2.1.1 lib/pact_broker/api/contracts/webhook_contract.rb
pact_broker-2.1.0 lib/pact_broker/api/contracts/webhook_contract.rb