sanket3280/code-execution
0
1export class EmailValidator {2 static isValidEmail(email) {3 const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;4 return emailRegex.test(email);5 }6 7 static sanitizeInput(input) {8 if (typeof input !== 'string') return '';9 return input.trim().replace(/[<>]/g, '');10 }11 12 static validateEmailData(data) {13 const errors = [];14 15 if (!data.to_email || !this.isValidEmail(data.to_email)) {16 errors.push('Invalid recipient email address');17 }18 19 if (!data.from_name || data.from_name.length < 2) {20 errors.push('Sender name must be at least 2 characters');21 }22 23 if (!data.message || data.message.length < 10) {24 errors.push('Message must be at least 10 characters');25 }26 27 return {28 isValid: errors.length === 0,29 errors30 };31 }32 }33 34 