Skip to content

Commit

Permalink
Merge pull request #136 from southpaw27/full-address-form-check
Browse files Browse the repository at this point in the history
add full address check for .@ as it is not allowed
  • Loading branch information
micke authored Sep 26, 2019
2 parents 023d4bf + 8cebcee commit 5075b26
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/valid_email2/address.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions spec/valid_email2_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5075b26

Please sign in to comment.