(email: string)
| 71 | * Quick email validation for client-side form feedback. |
| 72 | */ |
| 73 | export function quickValidateEmail(email: string): EmailValidationResult { |
| 74 | const checks = { |
| 75 | syntax: false, |
| 76 | domain: false, |
| 77 | mxRecord: true, |
| 78 | disposable: false, |
| 79 | } |
| 80 | |
| 81 | checks.syntax = validateEmailSyntax(email) |
| 82 | if (!checks.syntax) { |
| 83 | return { |
| 84 | isValid: false, |
| 85 | reason: 'Invalid email format', |
| 86 | confidence: 'high', |
| 87 | checks, |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | const domain = email.split('@')[1]?.toLowerCase() |
| 92 | if (!domain) { |
| 93 | return { |
| 94 | isValid: false, |
| 95 | reason: 'Missing domain', |
| 96 | confidence: 'high', |
| 97 | checks, |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | checks.disposable = !isDisposableEmail(email) |
| 102 | if (!checks.disposable) { |
| 103 | return { |
| 104 | isValid: false, |
| 105 | reason: 'Disposable email addresses are not allowed', |
| 106 | confidence: 'high', |
| 107 | checks, |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | if (hasInvalidPatterns(email)) { |
| 112 | return { |
| 113 | isValid: false, |
| 114 | reason: 'Email contains suspicious patterns', |
| 115 | confidence: 'medium', |
| 116 | checks, |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | checks.domain = domain.includes('.') && !domain.startsWith('.') && !domain.endsWith('.') |
| 121 | if (!checks.domain) { |
| 122 | return { |
| 123 | isValid: false, |
| 124 | reason: 'Invalid domain format', |
| 125 | confidence: 'high', |
| 126 | checks, |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | return { |
no test coverage detected