Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add full address check for .@ as it is not allowed #136

Merged
merged 1 commit into from
Sep 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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