(input: string)
| 62 | * @returns `true` if valid, or an error message string if invalid. |
| 63 | */ |
| 64 | export 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. |
no outgoing calls
no test coverage detected