aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrancesco Rodriguez <lrodriguezsanc@gmail.com>2012-06-23 14:49:22 -0500
committerFrancesco Rodriguez <lrodriguezsanc@gmail.com>2012-06-23 14:49:22 -0500
commitffe16b16cd8ca4fa838a08407b275a38b42b5dbc (patch)
tree547ca408acb5f3ebdda2c73a132abae0108fdbea
parent62a13093c0986993ed898e0e496d702a9716d139 (diff)
downloadrails-ffe16b16cd8ca4fa838a08407b275a38b42b5dbc.tar.gz
rails-ffe16b16cd8ca4fa838a08407b275a38b42b5dbc.tar.bz2
rails-ffe16b16cd8ca4fa838a08407b275a38b42b5dbc.zip
add description ActiveModel::StrictValidationField [ci skip]
-rw-r--r--activemodel/lib/active_model/errors.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb
index cfdd4d615d..7ee86d6444 100644
--- a/activemodel/lib/active_model/errors.rb
+++ b/activemodel/lib/active_model/errors.rb
@@ -281,6 +281,14 @@ module ActiveModel
#
# If +message+ is a proc, it will be called, allowing for things like
# <tt>Time.now</tt> to be used within an error.
+ #
+ # If the <tt>:strict</tt> option is set to true will raise
+ # ActiveModel::StrictValidationFailed instead of adding the error.
+ #
+ # person.errors.add(:name, nil, strict: true)
+ # # => ActiveModel::StrictValidationFailed: name is invalid
+ #
+ # person.errors.messages # => {}
def add(attribute, message = nil, options = {})
message = normalize_message(attribute, message, options)
if options[:strict]
@@ -427,6 +435,8 @@ module ActiveModel
end
end
+ # Raised when a validation cannot be corrected by end users and are considered
+ # exceptional
class StrictValidationFailed < StandardError
end
end