class EmailValidator
Validate email, works with UTF-8 The validation is intentionally simply, you can never be sure an email is valid anyway (a user can mistype gmail as gmaill, for example).
-
User part: one or more alphabet character or number or _ or -.
-
Domain part: one or more alphabet character or number or _ or -.
-
tld part: 2 or more alphabet characters, numbers, or -
Constants
- REGEXP
Public Instance Methods
validate_each(record, attribute, value)
click to toggle source
# File lib/validations/email_validator.rb, line 10 def validate_each(record, attribute, value) record.errors.add attribute, (options[:message] || I18n.t('rails_validation.email.invalid')) unless value =~ REGEXP end