email_check 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +18 -4
- data/lib/email_check.rb +9 -0
- data/lib/email_check/email_address.rb +4 -0
- data/lib/email_check/email_validator.rb +4 -0
- data/lib/email_check/version.rb +1 -1
- data/vendor/blocked_usernames.yml +21 -0
- 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: 2fa37a71c436036dacc36c1bf38d1fc276e3a644
|
4
|
+
data.tar.gz: 56c787b14b00b78172b51d0b12a58252d1de5d00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4837b5e6772915a42264e22a54e8d656cb5a30f596d899f74b0e97d199b620e68822e6eb73156a3fa5e25c9127e74af7ad4ba7b7051565f53d7da7a4b4200e32
|
7
|
+
data.tar.gz: e9c9d583eecec2a3395261f285fd53815875f9269539f4ae3f424faedf94c21b2a587e292b14c65c23b489a1afdd84cfe099d51ba03f018e0408994d2b909bb4
|
data/README.md
CHANGED
@@ -13,6 +13,8 @@ This gem provides a robust mechanism to validate email addresses and restrict ac
|
|
13
13
|
This gem also ships with a data-set of free and [disposable](http://en.wikipedia.org/wiki/Disposable_email_address)
|
14
14
|
email domains which are used for validation checks.
|
15
15
|
|
16
|
+
You can also block certain usernames from creating accounts. Examples: admin, root
|
17
|
+
|
16
18
|
### Validation mechanisms
|
17
19
|
- Uses the mail gem.
|
18
20
|
- Checks the domain's MX record
|
@@ -47,9 +49,20 @@ To validate that the domain is not blacklisted:
|
|
47
49
|
```ruby
|
48
50
|
validates :email, email: { blacklist:true}
|
49
51
|
```
|
52
|
+
|
53
|
+
To validate that the username is not blocked
|
54
|
+
```ruby
|
55
|
+
validates :email, email: { blocked_usernames:true }
|
56
|
+
|
50
57
|
Everything together:
|
51
58
|
```ruby
|
52
|
-
validates :email, email: {
|
59
|
+
validates :email, email: {
|
60
|
+
mx: true,
|
61
|
+
disposable:true,
|
62
|
+
free:true,
|
63
|
+
blacklist:true,
|
64
|
+
blocked_usernames:true,
|
65
|
+
message: "Please register with your corporate email" }
|
53
66
|
```
|
54
67
|
|
55
68
|
### Modifying inbuilt lists
|
@@ -64,17 +77,18 @@ EmailCheck.whitelisted_domains << 'gmail.com'
|
|
64
77
|
EmailCheck.free_email_domains << 'thenewgmail.com'
|
65
78
|
# Setting a domain in the blacklist also will blacklist all subdomains
|
66
79
|
EmailCheck.blacklisted_domains << 'lvh.me'
|
80
|
+
EmailCheck.blocked_usernames << 'anonymous'
|
67
81
|
```
|
68
82
|
|
69
83
|
## Requirements
|
70
|
-
This gem is tested with Rails 4.0
|
84
|
+
This gem is tested with Rails 4.0+. Ruby versions tested:
|
71
85
|
- Ruby 2.0
|
72
86
|
- Ruby 2.1
|
73
87
|
- Ruby 2.2
|
74
88
|
|
75
89
|
## Credits
|
76
|
-
This code is heavily based upon: [lisinge/valid_email2](https://github.com/lisinge/valid_email2)
|
77
|
-
Data is from: [lavab/disposable](https://github.com/lavab/disposable/blob/master/domains.txt) and
|
90
|
+
- This code is heavily based upon: [lisinge/valid_email2](https://github.com/lisinge/valid_email2)
|
91
|
+
- Data is from: [lavab/disposable](https://github.com/lavab/disposable/blob/master/domains.txt) and
|
78
92
|
[willwhite/freemail](https://github.com/willwhite/freemail/blob/master/data/free.txt)
|
79
93
|
|
80
94
|
[Gem Version]: https://rubygems.org/gems/email_check
|
data/lib/email_check.rb
CHANGED
@@ -6,6 +6,7 @@ module EmailCheck
|
|
6
6
|
@@disposable_email_domains ||= YAML.load_file(File.expand_path("../../vendor/disposable.yml", __FILE__))
|
7
7
|
@@free_email_domains ||= YAML.load_file(File.expand_path("../../vendor/free.yml", __FILE__))
|
8
8
|
@@blacklisted_domains ||= YAML.load_file(File.expand_path("../../vendor/blacklist.yml", __FILE__))
|
9
|
+
@@blocked_usernames ||= YAML.load_file(File.expand_path("../../vendor/blocked_usernames.yml", __FILE__))
|
9
10
|
|
10
11
|
# Disposable email providers
|
11
12
|
def self.disposable_email_domains
|
@@ -42,4 +43,12 @@ module EmailCheck
|
|
42
43
|
def self.whitelisted_domains=(list)
|
43
44
|
@@whitelisted_domains = list
|
44
45
|
end
|
46
|
+
|
47
|
+
def self.blocked_usernames
|
48
|
+
@@blocked_usernames ||= []
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.blocked_usernames=(list)
|
52
|
+
@@blocked_usernames = list
|
53
|
+
end
|
45
54
|
end
|
@@ -12,6 +12,10 @@ class EmailValidator < ActiveModel::EachValidator
|
|
12
12
|
|
13
13
|
return if address.whitelisted?
|
14
14
|
|
15
|
+
if options[:blocked_usernames]
|
16
|
+
error(record, attribute) && return if address.blocked_username?
|
17
|
+
end
|
18
|
+
|
15
19
|
if options[:disposable]
|
16
20
|
error(record, attribute) && return if address.disposable?
|
17
21
|
end
|
data/lib/email_check/version.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
---
|
2
|
+
- abuse
|
3
|
+
- admin
|
4
|
+
- api
|
5
|
+
- create
|
6
|
+
- delete
|
7
|
+
- destroy
|
8
|
+
- feedback
|
9
|
+
- help
|
10
|
+
- hostmaster
|
11
|
+
- index
|
12
|
+
- new
|
13
|
+
- noreply
|
14
|
+
- postmaster
|
15
|
+
- root
|
16
|
+
- show
|
17
|
+
- support
|
18
|
+
- unsubscribe
|
19
|
+
- unknown
|
20
|
+
- update
|
21
|
+
- workfeed
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: email_check
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Darshan Patil
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -132,6 +132,7 @@ files:
|
|
132
132
|
- lib/email_check/email_validator.rb
|
133
133
|
- lib/email_check/version.rb
|
134
134
|
- vendor/blacklist.yml
|
135
|
+
- vendor/blocked_usernames.yml
|
135
136
|
- vendor/disposable.yml
|
136
137
|
- vendor/free.yml
|
137
138
|
homepage: https://github.com/dapatil/email_check
|