Sha256: 52bab21e4c5509a540cec5b2e25adcf3a039bf20b1fecd45dd7cd0558da1034b

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

require 'dry/validation/constants'
require 'dry/validation/contract'
require 'dry/validation/macros'

# Main namespace
#
# @api public
module Dry
  # Main library namespace
  #
  # @api public
  module Validation
    extend Dry::Core::Extensions
    extend Macros::Registrar

    register_extension(:monads) do
      require 'dry/validation/extensions/monads'
    end

    register_extension(:hints) do
      require 'dry/validation/extensions/hints'
    end

    # Define a contract and build its instance
    #
    # @example
    #   my_contract = Dry::Validation.Contract do
    #     params do
    #       required(:name).filled(:string)
    #     end
    #   end
    #
    #   my_contract.call(name: "Jane")
    #
    # @param [Hash] options Contract options
    #
    # @see Contract
    #
    # @return [Contract]
    #
    # @api public
    def self.Contract(options = EMPTY_HASH, &block)
      Contract.build(options, &block)
    end

    # This is needed by Macros::Registrar
    #
    # @api private
    def self.macros
      Macros
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dry-validation-1.1.0 lib/dry/validation.rb
dry-validation-1.0.0 lib/dry/validation.rb