lib/dry/schema/message_compiler.rb in dry-schema-1.6.0 vs lib/dry/schema/message_compiler.rb in dry-schema-1.6.1

- old
+ new

@@ -2,12 +2,13 @@ require "dry/initializer" require "dry/schema/constants" require "dry/schema/message" -require "dry/schema/message_set" require "dry/schema/message_compiler/visitor_opts" +require "dry/schema/message_set" +require "dry/schema/path" module Dry module Schema # Compiles rule results AST into human-readable format # @@ -107,21 +108,11 @@ left end end # @api private - def visit_unexpected_key(node, _opts) - path, input = node - - msg = messages.translate("errors.unexpected_key") - - Message.new( - path: path, - meta: msg[:meta] || EMPTY_HASH, - text: msg[:text], - predicate: nil, - input: input - ) + def visit_unexpected_key(node, opts) + visit_predicate([:unexpected_key, []], opts.dup.update(path: Path[node.first])) end # @api private def visit_or(node, opts) left, right = node.map { |n| visit(n, opts) }