Class: EmailFormatValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- EmailFormatValidator
- Defined in:
- app/validators/email_format_validator.rb
Overview
Validates that an email address (or array of addresses) passes Truemail verification.
Instance Method Summary collapse
-
#validate_each(record, attribute, value) ⇒ void
Validates a single attribute value (or each element of an array) with Truemail.
Instance Method Details
#validate_each(record, attribute, value) ⇒ void
This method returns an undefined value.
Validates a single attribute value (or each element of an array) with Truemail.
11 12 13 14 15 |
# File 'app/validators/email_format_validator.rb', line 11 def validate_each(record, attribute, value) [value].flatten.filter_map(&:presence).each do |v| record.errors.add attribute, ([:message] || "#{v} is not a valid email") unless Truemail.valid?(v) end end |