lib/dry/schema/extensions/hints/message_compiler_methods.rb in dry-schema-0.2.0 vs lib/dry/schema/extensions/hints/message_compiler_methods.rb in dry-schema-0.3.0
- old
+ new
@@ -1,5 +1,7 @@
+# frozen_string_literal: true
+
module Dry
module Schema
module Extensions
module Hints
module MessageCompilerMethods
@@ -28,17 +30,22 @@
end
# @api private
def exclude?(messages, opts)
Array(messages).all? do |msg|
- hints = opts.hints.reject { |hint| msg == hint }.reject { |hint| hint.predicate == :filled? }
+ hints = opts
+ .hints
+ .reject { |hint| msg == hint }
+ .reject { |hint| hint.predicate == :filled? }
+
key_failure = opts.key_failure?(msg.path)
predicate = msg.predicate
(HINT_TYPE_EXCLUSION.include?(predicate) && !key_failure) ||
(msg.predicate == :filled? && key_failure) ||
- (!key_failure && HINT_TYPE_EXCLUSION.include?(predicate) && !hints.empty? && hints.any? { |hint| hint.path == msg.path }) ||
- HINT_OTHER_EXCLUSION.include?(predicate)
+ (!key_failure && HINT_TYPE_EXCLUSION.include?(predicate) &&
+ !hints.empty? && hints.any? { |hint| hint.path == msg.path }) ||
+ HINT_OTHER_EXCLUSION.include?(predicate)
end
end
# @api private
def message_type(options)