MCPcopy Create free account
hub / github.com/Linen-dev/linen.dev / isEmailValid

Function isEmailValid

packages/utilities/src/email.ts:8–25  ·  view source on GitHub ↗
(emailString: string)

Source from the content-addressed store, hash-verified

6 */
7
8export const isEmailValid = (emailString: string): boolean => {
9 // Regular expression pattern to validate email addresses
10 const emailPattern =
11 /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/;
12
13 // Split the email string by commas
14 const emails = emailString.split(',');
15
16 for (let i = 0; i < emails.length; i++) {
17 const email = emails[i].trim(); // Remove leading/trailing whitespace
18
19 if (!emailPattern.test(email)) {
20 return false; // Invalid email address
21 }
22 }
23
24 return true; // All email addresses are valid
25};

Callers 2

email.spec.tsFile · 0.90
createInviteFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected