7
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
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/email_check/email_validator.rb', line 7
def validate_each(record, attribute, value)
unless value.present?
add_error(record, attribute)
return
end
address = EmailCheck::EmailAddress.new(value)
unless address && address.format_valid?
add_error(record, attribute)
return
end
if options[:block_special_usernames] && address.blocked_username?
add_error(record, attribute)
return
end
return if address.whitelisted_domain?
if options[:not_disposable] && address.disposable?
add_error(record, attribute)
return
end
if options[:not_blacklisted] && address.blacklisted_domain?
add_error(record, attribute)
return
end
if options[:not_free] && address.free_email_provider?
add_error(record, attribute)
return
end
if options[:check_mx] && address.domain_has_mx? == false
add_error(record, attribute)
return
end
end
|