aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model/error.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activemodel/lib/active_model/error.rb')
-rw-r--r--activemodel/lib/active_model/error.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/activemodel/lib/active_model/error.rb b/activemodel/lib/active_model/error.rb
index 214a0b356d..b1912f2604 100644
--- a/activemodel/lib/active_model/error.rb
+++ b/activemodel/lib/active_model/error.rb
@@ -8,7 +8,7 @@ module ActiveModel
CALLBACKS_OPTIONS = [:if, :unless, :on, :allow_nil, :allow_blank, :strict]
MESSAGE_OPTIONS = [:message]
- def initialize(base, attribute, type, **options)
+ def initialize(base, attribute, type = :invalid, **options)
@base = base
@attribute = attribute
@raw_type = type
@@ -56,5 +56,11 @@ module ActiveModel
true
end
+
+ def strict_match?(attribute, type, **options)
+ return false unless match?(attribute, type, **options)
+
+ full_message == Error.new(@base, attribute, type, **options).full_message
+ end
end
end