export type ValidationResult = | { isValid: true } | { isValid: false; message: string }; // TODO: 세 함수를 모두 ValidationResult 타입으로 통일하세요. export function validateEmail(email: string): ValidationResult { if (!email) { return 'Email is required' as any; // 잘못된 반환 } if (!email.includes('@')) { return 'Invalid email format' as any; } return true as any; } export function validatePassword(password: string): ValidationResult { if (password.length < 8) { return { valid: false, error: 'Too short' } as any; } return { valid: true } as any; } export function validateUsername(username: string): ValidationResult { if (!username) { return { isValid: false } as any; // message 누락 } return { isValid: true, message: 'Valid' } as any; // 성공에 message는 불필요 }
Tests