lib/dry/data/constraints.rb in dry-data-0.4.2 vs lib/dry/data/constraints.rb in dry-data-0.5.0
- old
+ new
@@ -1,18 +1,26 @@
-require 'dry/validation/rule_compiler'
-require 'dry/validation/predicates'
+require 'dry/logic/rule_compiler'
+require 'dry/logic/predicates'
module Dry
module Data
+ module Predicates
+ include Logic::Predicates
+
+ predicate(:type?) do |type, value|
+ value.kind_of?(type)
+ end
+ end
+
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)
+ @rule_compiler ||= Logic::RuleCompiler.new(Data::Predicates)
end
end
end