/** * Provides strict e-mail address verification close to RFC * Includes support for unicode * * @param <string> E-mail address to verify * @returns <boolean> Returns true if e-mail address is considered to be valid, * false otherwise */ export default function validateEmail (email) { return typeof email === 'string' && 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('.-') }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter