Class: EmailFormatValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
app/validators/email_format_validator.rb

Overview

Custom validator: email format.

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



4
5
6
7
8
# File 'app/validators/email_format_validator.rb', line 4

def validate_each(record, attribute, value)
  [value].flatten.filter_map(&:presence).each do |v|
    record.errors.add attribute, (options[:message] || "#{v} is not a valid email") unless Truemail.valid?(v)
  end
end