提交 ca99ab24 编写于 作者: Y Yves Senn

make default value for `:message` on `AM::Errors` explicit.

上级 763635e3
......@@ -289,7 +289,7 @@ def to_hash(full_messages = false)
# # => NameIsInvalid: name is invalid
#
# person.errors.messages # => {}
def add(attribute, message = nil, options = {})
def add(attribute, message = :invalid, options = {})
message = normalize_message(attribute, message, options)
if exception = options[:strict]
exception = ActiveModel::StrictValidationFailed if exception == true
......@@ -331,7 +331,7 @@ def add_on_blank(attributes, options = {})
#
# person.errors.add :name, :blank
# person.errors.added? :name, :blank # => true
def added?(attribute, message = nil, options = {})
def added?(attribute, message = :invalid, options = {})
message = normalize_message(attribute, message, options)
self[attribute].include? message
end
......@@ -437,8 +437,6 @@ def generate_message(attribute, type = :invalid, options = {})
private
def normalize_message(attribute, message, options)
message ||= :invalid
case message
when Symbol
generate_message(attribute, message, options.except(*CALLBACKS_OPTIONS))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册