valid_email2 2.2.3 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +5 -0
- data/lib/valid_email2/address.rb +4 -0
- data/lib/valid_email2/email_validator.rb +4 -0
- data/lib/valid_email2/version.rb +1 -1
- data/lib/valid_email2.rb +5 -0
- data/spec/valid_email2_spec.rb +20 -0
- data/vendor/disposable_emails.yml +1 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c276bf084cb4c9815f285bea9a4e3074ef7e6f60751517e006421d4dff33d21d
|
4
|
+
data.tar.gz: 950da4a70ea385e7acab48193168a91874acd54520f295cba9c8d28f7fa3d875
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfd46b264bd9ded9820c279a62e02fb61bada67a7d62555a80cf094e6abd6d94d488f754a7837a67103476cfad3fd82f5f6443e49b9cdb29b1864a04fb381910
|
7
|
+
data.tar.gz: f31d60651d05f90e7ce63f8f2feab0f24eb37752dca65e63b29bd9d14782779b5ee6b824e77de12c590da6aa118aa73536ff4cdcad9be062576818ef9d99af86
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## Version 2.3.0
|
2
|
+
Add whitelist feature (https://github.com/lisinge/valid_email2/pull/119)
|
3
|
+
Update disposable emails (https://github.com/lisinge/valid_email2/pull/116)
|
4
|
+
|
1
5
|
## Version 2.2.3
|
2
6
|
Update disposable emails #113
|
3
7
|
Remove false positives (yandex.com, naver.com, com.ar)
|
data/README.md
CHANGED
@@ -53,6 +53,11 @@ To validate that the domain is not a disposable email:
|
|
53
53
|
validates :email, 'valid_email_2/email': { disposable: true }
|
54
54
|
```
|
55
55
|
|
56
|
+
To validate that the domain is not a disposable email or a disposable email but whitelisted (under vendor/whitelist.yml):
|
57
|
+
```ruby
|
58
|
+
validates :email, 'valid_email_2/email': { disposable_with_whitelist: true }
|
59
|
+
```
|
60
|
+
|
56
61
|
To validate that the domain is not blacklisted (under vendor/blacklist.yml):
|
57
62
|
```ruby
|
58
63
|
validates :email, 'valid_email_2/email': { blacklist: true }
|
data/lib/valid_email2/address.rb
CHANGED
@@ -24,6 +24,10 @@ module ValidEmail2
|
|
24
24
|
error(record, attribute) && return if address.disposable?
|
25
25
|
end
|
26
26
|
|
27
|
+
if options[:disposable_with_whitelist]
|
28
|
+
error(record, attribute) && return if address.disposable? && !address.whitelisted?
|
29
|
+
end
|
30
|
+
|
27
31
|
if options[:blacklist]
|
28
32
|
error(record, attribute) && return if address.blacklisted?
|
29
33
|
end
|
data/lib/valid_email2/version.rb
CHANGED
data/lib/valid_email2.rb
CHANGED
@@ -9,4 +9,9 @@ module ValidEmail2
|
|
9
9
|
blacklist_file = "vendor/blacklist.yml"
|
10
10
|
@@blacklist ||= File.exists?(blacklist_file) ? YAML.load_file(File.expand_path(blacklist_file)) : []
|
11
11
|
end
|
12
|
+
|
13
|
+
def self.whitelist
|
14
|
+
whitelist_file = "vendor/whitelist.yml"
|
15
|
+
@@whitelist ||= File.exists?(whitelist_file) ? YAML.load_file(File.expand_path(whitelist_file)) : []
|
16
|
+
end
|
12
17
|
end
|
data/spec/valid_email2_spec.rb
CHANGED
@@ -16,6 +16,10 @@ class TestUserDisallowDisposable < TestModel
|
|
16
16
|
validates :email, 'valid_email_2/email': { disposable: true }
|
17
17
|
end
|
18
18
|
|
19
|
+
class TestUserDisallowDisposableWithWhitelist < TestModel
|
20
|
+
validates :email, 'valid_email_2/email': { disposable_with_whitelist: true }
|
21
|
+
end
|
22
|
+
|
19
23
|
class TestUserDisallowBlacklisted < TestModel
|
20
24
|
validates :email, 'valid_email_2/email': { blacklist: true }
|
21
25
|
end
|
@@ -82,6 +86,22 @@ describe ValidEmail2 do
|
|
82
86
|
user = TestUserDisallowDisposable.new(email: "foo@example.com")
|
83
87
|
expect(user.valid?).to be_truthy
|
84
88
|
end
|
89
|
+
|
90
|
+
describe "with whitelisted emails" do
|
91
|
+
it "should be invalid when the domain is in the list of disposable and there is no whitelist" do
|
92
|
+
user = TestUserDisallowDisposableWithWhitelist.new(email: "foo@#{ValidEmail2.disposable_emails.first}")
|
93
|
+
expect(user.valid?).to be_falsey
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should be valid when the domain is in the list of disposable but it is in the whitelist" do
|
97
|
+
whitelist_domain = ValidEmail2.disposable_emails.first
|
98
|
+
whitelist_file_path = "vendor/whitelist.yml"
|
99
|
+
File.open(whitelist_file_path, "w") {|f| f.write whitelist_domain.to_yaml }
|
100
|
+
user = TestUserDisallowDisposableWithWhitelist.new(email: "foo@#{whitelist_domain}")
|
101
|
+
expect(user.valid?).to be_falsey
|
102
|
+
File.delete(whitelist_file_path)
|
103
|
+
end
|
104
|
+
end
|
85
105
|
end
|
86
106
|
|
87
107
|
describe "blacklisted emails" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: valid_email2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Micke Lisinge
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -128,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
128
|
version: '0'
|
129
129
|
requirements: []
|
130
130
|
rubyforge_project:
|
131
|
-
rubygems_version: 2.7.
|
131
|
+
rubygems_version: 2.7.6
|
132
132
|
signing_key:
|
133
133
|
specification_version: 4
|
134
134
|
summary: ActiveModel validation for email. Including MX lookup and disposable email
|