valid_email2 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/valid_email2.rb +7 -1
- data/lib/valid_email2/version.rb +1 -1
- data/spec/valid_email2_spec.rb +6 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98aa3e19a6868c3b3ac44bbbb7fed732016eda42
|
4
|
+
data.tar.gz: 5993dc5dfcfb1661ce2af3a937226b061fb5f23b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf6895efe18e256a5115cbee046476684a8084fb5df6fbbdf41d99cc3ecb65c08e5758e864daf86b3c8587accf929a706beb8dbd908cfd89f40f7c3be2914a7d
|
7
|
+
data.tar.gz: 9bade03f341ba245864a1808930c0451e034c9688cd05d5700cb798098417283238ef4c074d2eaea1cd64adb6569384b660e2aa0b8ea7e47b3df318927139533
|
data/lib/valid_email2.rb
CHANGED
@@ -16,7 +16,13 @@ class EmailValidator < ActiveModel::EachValidator
|
|
16
16
|
def validate_each(record, attribute, value)
|
17
17
|
return unless value.present?
|
18
18
|
options = default_options.merge(self.options)
|
19
|
-
|
19
|
+
|
20
|
+
begin
|
21
|
+
email = Mail::Address.new(value)
|
22
|
+
rescue Mail::Field::ParseError
|
23
|
+
error(record, attribute)
|
24
|
+
return
|
25
|
+
end
|
20
26
|
|
21
27
|
if email.domain && email.address == value
|
22
28
|
tree = email.send(:tree)
|
data/lib/valid_email2/version.rb
CHANGED
data/spec/valid_email2_spec.rb
CHANGED
@@ -24,6 +24,12 @@ describe ValidEmail2 do
|
|
24
24
|
user = TestUser.new(email: "foo@bar")
|
25
25
|
user.valid?.should be_false
|
26
26
|
end
|
27
|
+
|
28
|
+
it "should be invalid if Mail::AddressListsParser raises exception" do
|
29
|
+
user = TestUser.new(email: "foo@gmail.com")
|
30
|
+
Mail::Address.stub(:new).and_raise(Mail::Field::ParseError.new(nil, nil, nil))
|
31
|
+
user.valid?.should be_false
|
32
|
+
end
|
27
33
|
end
|
28
34
|
|
29
35
|
describe "disposable emails" do
|