提交 ea2ad26a 编写于 作者: X Xavier Noria

you rarely want ^ or $ in validations, use \A when you mean \A

上级 c9240687
......@@ -28,7 +28,7 @@ module ClassMethods
# class EmailValidator < ActiveModel::EachValidator
# def validate_each(record, attribute, value)
# record.errors[attribute] << (options[:message] || "is not an email") unless
# value =~ /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
# value =~ /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
# end
# end
#
......@@ -48,7 +48,7 @@ module ClassMethods
#
# class TitleValidator < ActiveModel::EachValidator
# def validate_each(record, attribute, value)
# record.errors[attribute] << "must start with 'the'" unless value =~ /^the/i
# record.errors[attribute] << "must start with 'the'" unless value =~ /\Athe/i
# end
# end
#
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册