blob: cff47ac230cedb814728d94a26583423a476586b (
plain) (
blame)
1
2
3
4
5
6
|
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
end
end
|