Last active
January 15, 2025 21:26
-
-
Save juliyvchirkov/30337123712f345fab264516800d6302 to your computer and use it in GitHub Desktop.
javascript: strict e-mail address verification
This file contains hidden or 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
/** | |
* Provides strict verification of e-mail address | |
* Includes support for unicode | |
* | |
* @param string E-mail address to verify | |
* @return boolean True if e-mail address is valid, false otherwise | |
*/ | |
const validEmail = (email) => | |
Object.prototype.toString.call(email).slice(8, -1) === String.name && | |
email && | |
email.length < 256 && | |
/^(?:[0-z!#$%&'*+/=?^_`{|}.~-]|[^\u0000-\u007F]){1,64}@(?:(?:[0-z-]|[^\u0000-\u007F]){1,62}\.)+(?:[0-z]|[^\u0000-\u007F]){2,63}$/i.test(email) && | |
!(email.includes('..') || | |
email.startsWith('.') || | |
email.includes('.@') || | |
email.includes('-.') || | |
email.includes('.-')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment