Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | export class Validators { static validatePhoneNumber(phoneNumber: string): boolean { if (!phoneNumber) return false; const phoneRegex = /^(\+[1-9]\d{1,14}|0\d{9,14})$/; return phoneRegex.test(phoneNumber); } static validateEmail(email: string): boolean { if (!email) return false; const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; return emailRegex.test(email); } static validateSubscription(type: string, seats?: number, frequency?: string): { valid: boolean; message?: string } { if (!type || !['STANDARD', 'UNLIMITED'].includes(type)) { return { valid: false, message: 'Type d\'abonnement invalide' }; } if (type === 'STANDARD' && (!seats || seats < 1)) { return { valid: false, message: 'Nombre de sièges invalide' }; } if (!frequency || !['monthly', 'yearly'].includes(frequency)) { return { valid: false, message: 'Fréquence invalide' }; } return { valid: true }; } static validateTableName(tableName: string): boolean { return /^[a-zA-Z_][a-zA-Z0-9_]*$/.test(tableName); } } |