valid_email 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/config/locales/sv.yml +5 -0
- data/lib/valid_email/email_validator.rb +15 -19
- data/lib/valid_email/validate_email.rb +16 -15
- data/lib/valid_email/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dfc486fd0dfb112acae3207a3d736b5209daedb8
|
4
|
+
data.tar.gz: c4e004a30caf02049223de8ae0f0bbf8eec8e2ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f819b01ba5a32c6dbf8b076f3a4adc8ba7113d7ad2ebef9844ceaaa52386afa7b767894e37216771b04b16e5c6c8cc1cf1a2d8c0f3bade63f340de3bb8161b7
|
7
|
+
data.tar.gz: fcb080bf8c42242267320265e878680c3dac036d3bd5364f9629cbb16b8a93ba1488c98ee2f4d3ffbd8b5593a2bf5d167fc411ac706e1e863b4e41ba685401f4
|
data/README.md
CHANGED
@@ -85,6 +85,10 @@ nil.email? # => false
|
|
85
85
|
"john@gmail.com".email? # => May return true if it exists. It accepts a hash of options like ValidateEmail.valid?
|
86
86
|
```
|
87
87
|
|
88
|
+
## Code Status
|
89
|
+
|
90
|
+
* [![Build Status](https://travis-ci.org/hallelujah/valid_email.svg?branch=master)](https://travis-ci.org/hallelujah/valid_email)
|
91
|
+
|
88
92
|
# Credits
|
89
93
|
|
90
94
|
* Ramihajamalala Hery hery[at]rails-royce.org
|
@@ -4,26 +4,22 @@ require 'mail'
|
|
4
4
|
require 'valid_email/validate_email'
|
5
5
|
class EmailValidator < ActiveModel::EachValidator
|
6
6
|
def validate_each(record,attribute,value)
|
7
|
-
|
8
|
-
|
9
|
-
return if options[:allow_blank] && value.blank?
|
7
|
+
return if options[:allow_nil] && value.nil?
|
8
|
+
return if options[:allow_blank] && value.blank?
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
25
|
-
rescue Exception => e
|
26
|
-
r = false
|
10
|
+
r = ValidateEmail.valid?(value)
|
11
|
+
# Check if domain has DNS MX record
|
12
|
+
if r && options[:mx]
|
13
|
+
require 'valid_email/mx_validator'
|
14
|
+
r &&= MxValidator.new(:attributes => attributes).validate(record)
|
15
|
+
elsif r && options[:mx_with_fallback]
|
16
|
+
require 'valid_email/mx_with_fallback_validator'
|
17
|
+
r &&= MxWithFallbackValidator.new(:attributes => attributes).validate(record)
|
18
|
+
end
|
19
|
+
# Check if domain is disposable
|
20
|
+
if r && options[:ban_disposable_email]
|
21
|
+
require 'valid_email/ban_disposable_email_validator'
|
22
|
+
r &&= BanDisposableEmailValidator.new(:attributes => attributes).validate(record)
|
27
23
|
end
|
28
24
|
record.errors.add attribute, (options[:message] || I18n.t(:invalid, :scope => "valid_email.validations.email")) unless r
|
29
25
|
end
|
@@ -9,19 +9,20 @@ class ValidateEmail
|
|
9
9
|
m = Mail::Address.new(value)
|
10
10
|
# We must check that value contains a domain and that value is an email address
|
11
11
|
r = m.domain && m.address == value
|
12
|
+
if r
|
13
|
+
# Check that domain consists of dot-atom-text elements > 1
|
14
|
+
# In mail 2.6.1, domains are invalid per rfc2822 are parsed when they shouldn't
|
15
|
+
# This is to make sure we cover those cases
|
16
|
+
domain_dot_elements = m.domain.split(/\./)
|
17
|
+
r &&= domain_dot_elements.none?(&:blank?) && domain_dot_elements.size > 1
|
12
18
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
# Check if domain has DNS MX record
|
20
|
-
if r && options[:mx]
|
21
|
-
require 'valid_email/mx_validator'
|
22
|
-
r &&= mx_valid?(email)
|
19
|
+
# Check if domain has DNS MX record
|
20
|
+
if r && options[:mx]
|
21
|
+
require 'valid_email/mx_validator'
|
22
|
+
r &&= mx_valid?(email)
|
23
|
+
end
|
23
24
|
end
|
24
|
-
rescue
|
25
|
+
rescue Mail::Field::ParseError
|
25
26
|
r = false
|
26
27
|
end
|
27
28
|
r
|
@@ -39,7 +40,7 @@ class ValidateEmail
|
|
39
40
|
end
|
40
41
|
r = mx.size > 0
|
41
42
|
end
|
42
|
-
rescue
|
43
|
+
rescue Mail::Field::ParseError
|
43
44
|
r = false
|
44
45
|
end
|
45
46
|
r
|
@@ -54,13 +55,13 @@ class ValidateEmail
|
|
54
55
|
begin
|
55
56
|
m = Mail::Address.new(value)
|
56
57
|
r = !BanDisposableEmailValidator.config.include?(m.domain) if m.domain
|
57
|
-
rescue
|
58
|
+
rescue Mail::Field::ParseError
|
58
59
|
r = false
|
59
60
|
end
|
60
|
-
|
61
|
+
|
61
62
|
r
|
62
63
|
end
|
63
64
|
|
64
65
|
end
|
65
66
|
|
66
|
-
end
|
67
|
+
end
|
data/lib/valid_email/version.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ValidEmailVersion = "0.0.
|
1
|
+
ValidEmailVersion = "0.0.9"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: valid_email
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ramihajamalala Hery
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -86,6 +86,7 @@ files:
|
|
86
86
|
- config/locales/fr.yml
|
87
87
|
- config/locales/pl.yml
|
88
88
|
- config/locales/ru.yml
|
89
|
+
- config/locales/sv.yml
|
89
90
|
- config/valid_email.yml
|
90
91
|
- lib/valid_email.rb
|
91
92
|
- lib/valid_email/all.rb
|