blob: 9b74d83b37d5e20873c0bdc2b5685e84953ed4fc (
plain) (
blame)
1
2
3
4
5
6
7
|
class EmailValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
record.errors[attribute] << (options[:message] || "is not an email") unless
/\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i.match?(value)
end
end
|