aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model/errors.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activemodel/lib/active_model/errors.rb')
-rw-r--r--activemodel/lib/active_model/errors.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb
index 36819553ee..843c0c3cb5 100644
--- a/activemodel/lib/active_model/errors.rb
+++ b/activemodel/lib/active_model/errors.rb
@@ -63,7 +63,7 @@ module ActiveModel
class Errors
include Enumerable
- CALLBACKS_OPTIONS = [:if, :unless, :on, :allow_nil, :allow_blank]
+ CALLBACKS_OPTIONS = [:if, :unless, :on, :allow_nil, :allow_blank, :strict]
attr_reader :messages
@@ -218,6 +218,9 @@ module ActiveModel
elsif message.is_a?(Proc)
message = message.call
end
+ if options[:strict]
+ raise ActiveModel::StrictValidationFailed, message
+ end
self[attribute] << message
end
@@ -319,4 +322,7 @@ module ActiveModel
I18n.translate(key, options)
end
end
+
+ class StrictValidationFailed < StandardError
+ end
end