-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow dotless email addresses in
isEmail
- Loading branch information
Showing
2 changed files
with
8 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -215,13 +215,16 @@ isPhoneNumber text = Failure "is not a valid phone number (has to start with +, | |
-- >>> isEmail "ॐ@मणिपद्मे.हूँ" | ||
-- Success | ||
-- | ||
-- >>> isEmail "marc@localhost" -- missing TLD | ||
-- Failure "is not a valid email" | ||
-- >>> isEmail "marc@localhost" -- Although discouraged by ICANN, dotless TLDs are legal. See https://www.icann.org/news/announcement-2013-08-30-en | ||
-- Success | ||
-- | ||
-- >>> isEmail "loremipsum" | ||
-- Failure "is not a valid email" | ||
-- | ||
-- >>> isEmail "A@b@[email protected]" | ||
-- Failure "is not a valid email" | ||
isEmail :: Text -> ValidatorResult | ||
isEmail text | text =~ ("^[^ @]+@[^ @_+]+\\.[^ @_+-]+$" :: Text) = Success | ||
isEmail text | text =~ ("^[^ @]+@[^ @_+]+\\.?[^ @_+-]+$" :: Text) = Success | ||
isEmail text = Failure "is not a valid email" | ||
{-# INLINE isEmail #-} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters