1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

add description ActiveModel::StrictValidationField [ci skip]

This commit is contained in:
Francesco Rodriguez 2012-06-23 14:49:22 -05:00
parent 62a13093c0
commit ffe16b16cd

View file

@ -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