Class: NetHTTP::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/request/schema.rb

Defined Under Namespace

Classes: SchemaError

Constant Summary collapse

Schema =
Dry::Validation.Schema do
  configure do
    def name
      'NetHTTP::Request::Schema'
    end
  end

  required(:method).filled(type?: String)
  optional(:headers).maybe(type?: Hash)
  optional(:body).maybe
  optional(:query).filled(type?: String)

  rule(if_url_and_uri_are_nil_must_provide_path: [:uri, :url, :path]) do |uri, url, path|
    uri.empty?.then(url.empty?.then(path.filled?))
  end
end