Class: EmailFormatValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- EmailFormatValidator
- Defined in:
- lib/email_format_validator.rb
Defined Under Namespace
Modules: Patterns
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/email_format_validator.rb', line 23 def validate_each(record, attribute, value) pattern_choosed = [:rfc] ? Patterns::EMAIL : Patterns::LESS_RFC_COMPLIANT_EMAIL unless value =~ pattern_choosed record.errors.add(attribute, [:message] || (record, attribute)) end end |