lib/dry/validation/message_set.rb in dry-validation-1.0.0.beta2 vs lib/dry/validation/message_set.rb in dry-validation-1.0.0.rc1

- old
+ new

@@ -23,11 +23,11 @@ attr_reader :locale # @api private def initialize(messages, options = EMPTY_HASH) @locale = options.fetch(:locale, :en) - @source_messages = options.fetch(:source, messages.dup) + @source_messages = options.fetch(:source) { messages.dup } super end # Return a new message set using updated options # @@ -36,11 +36,11 @@ # @api private def with(other, new_options = EMPTY_HASH) return self if new_options.empty? self.class.new( - other + select { |err| err.is_a?(Message) }, + (other + select { |err| err.is_a?(Message) }).uniq, options.merge(source: source_messages, **new_options) ).freeze end # Add a new message @@ -99,10 +99,10 @@ # @api private def messages_map @messages_map ||= reduce(placeholders) { |hash, msg| node = msg.path.reduce(hash) { |a, e| a.is_a?(Hash) ? a[e] : a.last[e] } - (node.size > 1 ? node[0] : node) << msg.dump + (node[0].is_a?(::Array) ? node[0] : node) << msg.dump hash } end # @api private