Sha256: ac25977be48b0e7ed575bd04aa3e02b3106523a54ddbb2c07610ed29f91cf4f8

Contents?: true

Size: 840 Bytes

Versions: 2

Compression:

Stored size: 840 Bytes

Contents

# frozen_string_literal: true

require 'dry/equalizer'
require 'dry/initializer'

module Dry
  module Validation
    # Rules are created by contracts
    #
    # @api private
    class Rule
      include Dry::Equalizer(:name, :block)

      extend Dry::Initializer

      # @!atrribute [r] keys
      #   @return [Array<Symbol, String, Hash>]
      #   @api private
      option :keys

      # @!atrribute [r] block
      #   @return [Proc]
      #   @api private
      option :block

      # Evaluate the rule within the provided context
      #
      # @param [Contract] contract
      # @param [Result] result
      # @param [Concurrent::Map] context
      #
      # @api private
      def call(contract, result, context)
        Evaluator.new(contract, values: result, keys: keys, _context: context, &block)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dry-validation-1.0.0.beta2 lib/dry/validation/rule.rb
dry-validation-1.0.0.beta1 lib/dry/validation/rule.rb