Sha256: 5e5a454d35f1f691445b9b81034121b5c3b31ac965356b93bc98360f1db23cff

Contents?: true

Size: 422 Bytes

Versions: 4

Compression:

Stored size: 422 Bytes

Contents

require 'dry/validation/rule_compiler'
require 'dry/validation/predicates'

module Dry
  module Data
    def self.Rule(primitive, options)
      rule_compiler.(
        options.map { |key, val|
          [:val, [primitive, [:predicate, [:"#{key}?", [val]]]]]
        }
      ).reduce(:and)
    end

    def self.rule_compiler
      @rule_compiler ||= Validation::RuleCompiler.new(Validation::Predicates)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dry-data-0.4.2 lib/dry/data/constraints.rb
dry-data-0.4.1 lib/dry/data/constraints.rb
dry-data-0.4.0 lib/dry/data/constraints.rb
dry-data-0.3.2 lib/dry/data/constraints.rb