| export function validateEmail(email: string): boolean { | |
| const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; | |
| return emailRegex.test(email); | |
| } | |
| export function validatePassword(password: string): { valid: boolean; errors: string[] } { | |
| const errors: string[] = []; | |
| if (password.length < 8) { | |
| errors.push('Password must be at least 8 characters long'); | |
| } | |
| if (!/[A-Z]/.test(password)) { | |
| errors.push('Password must contain at least one uppercase letter'); | |
| } | |
| if (!/[a-z]/.test(password)) { | |
| errors.push('Password must contain at least one lowercase letter'); | |
| } | |
| if (!/[0-9]/.test(password)) { | |
| errors.push('Password must contain at least one number'); | |
| } | |
| if (!/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/.test(password)) { | |
| errors.push('Password must contain at least one special character'); | |
| } | |
| return { | |
| valid: errors.length === 0, | |
| errors, | |
| }; | |
| } | |
| export function sanitizeInput(input: string): string { | |
| return input.trim().replace(/[<>]/g, ''); | |
| } | |