MCPcopy Create free account
hub / github.com/PalisadoesFoundation/talawa-api / validateEmail

Function validateEmail

scripts/setup/validators.ts:64–76  ·  view source on GitHub ↗
(input: string)

Source from the content-addressed store, hash-verified

62 * @returns `true` if valid, or an error message string if invalid.
63 */
64export function validateEmail(input: string): true | string {
65 if (!input.trim()) {
66 return "Email cannot be empty.";
67 }
68 if (input.length > 254) {
69 return "Email is too long.";
70 }
71 const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
72 if (!emailRegex.test(input)) {
73 return "Invalid email format. Please enter a valid email address.";
74 }
75 return true;
76}
77
78/**
79 * Validates CloudBeaver admin username.

Callers 2

validators.test.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected