lib/dry/validation/schema_compiler.rb in dry-validation-0.9.5 vs lib/dry/validation/schema_compiler.rb in dry-validation-0.10.0

- old
+ new

@@ -12,18 +12,22 @@ def call(input, results) rule.(input) if deps_valid?(results) end + def with(options) + self.class.new(rule.with(options), deps) + end + private def deps_valid?(results) deps.all? do |path| result = nil Array(path).each do |name| curr = results[name] - result = curr.success? if curr.respond_to?(:success) + result = curr.success? if curr end result end end end @@ -35,11 +39,21 @@ super(*args) @options = options @schema = predicates.schema end + def visit_rule(node) + id, other = node + visit(other).with(id: id) + end + def visit_predicate(node) - super.evaluate_args!(schema) + super.eval_args(schema) + end + + def visit_custom(node) + id, predicate = node + Logic::Rule.new(predicate).with(id: id).bind(schema) end def visit_schema(klass) opt_keys = klass.config.options.keys opt_vals = options.values_at(*opt_keys).compact