9 lines
311 B
TypeScript
Executable File
9 lines
311 B
TypeScript
Executable File
const matcher =
|
|
/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
|
|
|
|
export function isEmail(string?: string): boolean {
|
|
if (!string) return false;
|
|
if (string.length > 320) return false;
|
|
return matcher.test(string);
|
|
}
|