mirror of
https://github.com/danbee/danbarberphoto
synced 2025-03-04 08:49:07 +00:00
11 lines
278 B
Ruby
11 lines
278 B
Ruby
# lib/email_validator.rb
|
|
class EmailValidator < ActiveModel::EachValidator
|
|
|
|
def validate_each(object, attribute, value)
|
|
unless value =~ /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
|
|
object.errors[attribute] << (options[:message] || "is not valid")
|
|
end
|
|
end
|
|
|
|
end
|