Class: RealWorldEmailValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- RealWorldEmailValidator
- Defined in:
- lib/real_world_email_validator.rb
Overview
Email address validator based on RFC 5322, plus own flavors that real world needs ref: tools.ietf.org/html/rfc5322#section-3.4.1
Defined Under Namespace
Modules: StringExt
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/real_world_email_validator.rb', line 22 def validate_each(record, attribute, value) if value.blank? record.errors.add attribute, :invalid return end username, domain = value.split('@') unless domain.present? && username_valid?(username) && domain_valid?(domain) record.errors.add attribute, :invalid end end |