Skip to content

Commit

Permalink
Merge pull request #1 from substancelab/do-not-accept-whitespace
Browse files Browse the repository at this point in the history
validator does not accept spaces in an email address
  • Loading branch information
koppen committed Apr 21, 2015
2 parents 74bdcf3 + 5aa2af9 commit 433f38d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/activemodel_email_address_validator/email_address.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def valid_using_regex?(regex)
end

def valid_using_default?
return false if address =~ /\s+/
email_parts = address.split('@')

return false unless email_parts.size == 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ def test_rejects_email_address_without_at_sign
reject("bobexample.com")
end

def test_rejects_any_space
reject("John. Doe. somewhere@gmail.com")
end

def test_rejects_nil
reject(nil)
end
Expand Down

0 comments on commit 433f38d

Please sign in to comment.