diff --git a/lib/valid_email2/address.rb b/lib/valid_email2/address.rb index 6c01c59..2230226 100644 --- a/lib/valid_email2/address.rb +++ b/lib/valid_email2/address.rb @@ -34,7 +34,9 @@ def valid? # Domain may not have two consecutive dots domain !~ /\.{2,}/ && # Domain may not start with a dot - domain !~ /^\./ + domain !~ /^\./ && + # Address may not contain a dot directly before @ + address.address !~ /\.@/ else false end diff --git a/spec/valid_email2_spec.rb b/spec/valid_email2_spec.rb index 8daa50a..3ee4d73 100644 --- a/spec/valid_email2_spec.rb +++ b/spec/valid_email2_spec.rb @@ -75,6 +75,11 @@ class TestUserMessage < TestModel user = TestUser.new(email: "foo🙈@gmail.com") expect(user.valid?).to be_falsy end + + it "is invalid if the domain contains .@ consecutively" do + user = TestUser.new(email: "foo.@gmail.com") + expect(user.valid?).to be_falsy + end end describe "with disposable validation" do