8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/rails_email_checker/email_validator.rb', line 8
def validate_each(record, attribute, value)
if !value.present? || value.nil?
add_error(record, attribute, :blank)
return
end
address = RailsEmailChecker::Address.new(value)
return if address.whitelisted?
if options[:formatted] && !address.formatted?
add_error(record, attribute)
return
end
if options[:blacklisted] && address.blacklisted?
add_error(record, attribute)
return
end
if options[:no_sub_addressed] && address.sub_addressed?
add_error(record, attribute)
return
end
if options[:recorded] && !address.recorded?
add_error(record, attribute)
nil
end
end
|