Sha256: a4cd64a3ba4942aa0ff25604792de555b271a5f02e17683685ed80de8b37c93f

Contents?: true

Size: 482 Bytes

Versions: 2

Compression:

Stored size: 482 Bytes

Contents

require 'dry-equalizer' # FIXME: this should not be needed

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

2 entries across 2 versions & 1 rubygems

Version Path
dry-data-0.3.1 lib/dry/data/constraints.rb
dry-data-0.3.0 lib/dry/data/constraints.rb