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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a5b67a49b88b65e4dcd7c8ad0c0210c998f863df
4
- data.tar.gz: ba27151ed1ea3122408e0e2f8873d126739788f7
3
+ metadata.gz: 98aa3e19a6868c3b3ac44bbbb7fed732016eda42
4
+ data.tar.gz: 5993dc5dfcfb1661ce2af3a937226b061fb5f23b
5
5
  SHA512:
6
- metadata.gz: 7ae2b937fa2b3fa3d735d4da25f33dbdddfb465e41188605a9f4106e920d56f50930eb7fe95cf5e172de8aa23b1dcaa4600511a90ee5a4e3daf9c5f29631d049
7
- data.tar.gz: 4ba1cde48caa146d4516ec5145d57fb18bf2ca735b12bfc6b3663ef1e246a9c9f658b5cd89c248d63afb29d03e57ca587c5be28fd915210aca78055bff6722d5
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
- email = Mail::Address.new(value)
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)
@@ -1,3 +1,3 @@
1
1
  module ValidEmail2
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: valid_email2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Micke Lisinge