lib/dry/validation/rule.rb in dry-validation-1.2.0 vs lib/dry/validation/rule.rb in dry-validation-1.2.1
- old
+ new
@@ -80,17 +80,19 @@
root = keys[0]
macros = parse_macros(*macros)
@keys = []
@block = proc do
- (values[root] || []).each_with_index do |_, idx|
- path = [*Schema::Path[root].to_a, idx]
+ unless result.base_error?(root) || !values.key?(root)
+ values[root].each_with_index do |_, idx|
+ path = [*Schema::Path[root].to_a, idx]
- next if result.error?(path)
+ next if result.error?(path)
- evaluator = with(macros: macros, keys: [path], &block)
+ evaluator = with(macros: macros, keys: [path], &block)
- failures.concat(evaluator.failures)
+ failures.concat(evaluator.failures)
+ end
end
end
@block_options = map_keywords(block) if block