email_verifier 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -0
- data/lib/email_verifier/validates_email_realness.rb +28 -27
- data/lib/email_verifier/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -71,6 +71,7 @@ Please send questions to [kamil@endpoint.com](mailto:kamil@endpoint.com)
|
|
71
71
|
* Francesco Gnarra ([https://github.com/francescognarra]())
|
72
72
|
* Stefan Wienert ([https://github.com/zealot128]())
|
73
73
|
* [https://github.com/mzabaljauregui]()
|
74
|
+
* Ethan Czahor ([https://github.com/czahor]())
|
74
75
|
|
75
76
|
## Contributing yourself
|
76
77
|
|
@@ -1,34 +1,35 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
module EmailVerifier
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
1
|
+
ActiveSupport.on_load(:active_record) do
|
2
|
+
|
3
|
+
module EmailVerifier
|
4
|
+
module ValidatesEmailRealness
|
5
|
+
|
6
|
+
module Validator
|
7
|
+
class EmailRealnessValidator < ActiveModel::EachValidator
|
8
|
+
def validate_each(record, attribute, value)
|
9
|
+
begin
|
10
|
+
record.errors.add attribute, I18n.t('errors.messages.email_verifier.email_not_real') unless EmailVerifier.check(value)
|
11
|
+
rescue EmailVerifier::OutOfMailServersException
|
12
|
+
record.errors.add attribute, I18n.t('errors.messages.email_verifier.out_of_mail_server')
|
13
|
+
rescue EmailVerifier::NoMailServerException
|
14
|
+
record.errors.add attribute, I18n.t('errors.messages.email_verifier.no_mail_server')
|
15
|
+
rescue EmailVerifier::FailureException
|
16
|
+
record.errors.add attribute, I18n.t('errors.messages.email_verifier.failure')
|
17
|
+
rescue Exception
|
18
|
+
record.errors.add attribute, I18n.t('errors.messages.email_verifier.exception')
|
19
|
+
end
|
19
20
|
end
|
20
21
|
end
|
21
22
|
end
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
|
24
|
+
module ClassMethods
|
25
|
+
def validates_email_realness_of(*attr_names)
|
26
|
+
validates_with ActiveRecord::Base::EmailRealnessValidator, _merge_attributes(attr_names)
|
27
|
+
end
|
27
28
|
end
|
29
|
+
|
28
30
|
end
|
29
|
-
|
30
31
|
end
|
32
|
+
|
33
|
+
ActiveRecord::Base.send(:include, EmailVerifier::ValidatesEmailRealness::Validator)
|
34
|
+
ActiveRecord::Base.send(:extend, EmailVerifier::ValidatesEmailRealness::ClassMethods)
|
31
35
|
end
|
32
|
-
|
33
|
-
ActiveRecord::Base.send(:include, EmailVerifier::ValidatesEmailRealness::Validator)
|
34
|
-
ActiveRecord::Base.send(:extend, EmailVerifier::ValidatesEmailRealness::ClassMethods)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: email_verifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-03-
|
12
|
+
date: 2015-03-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|