1class Validate { 2 static sanitizeText( text ) { 3 if (!text) return false; 4 text = text.trim(); 5 return text.length >= 3; 6 } 7 8 static isTelefone(telefone) { 9 if (!telefone) return false; 10 const numeros = telefone.replace(/\D/g, ''); 11 return numeros.length === 10 || numeros.length === 11; 12 } 13 14 static isEmail(email) { 15 if (!email) return false; 16 return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email); 17 } 18 19 static sanitizeNumber(quantidade) { 20 const num = parseInt(quantidade, 10); 21 return !isNaN(num) && num >= 1; 22 } 23 24 static isSelected(element) { 25 if (!element) return false; 26 return element.value !== 'none'; 27 } 28 29 static isCpf(cpf) 30 { 31 if (!cpf) return false; 32 cpf = cpf.replace(/[^\d]+/g, ''); 33 if (cpf.length !== 11) return false; 34 if (/^(\d)\1{10}$/.test(cpf)) return false; 35 let soma = 0; 36 let resto; 37 for (let i = 1; i <= 9; i++) { 38 soma += parseInt(cpf.substring(i - 1, i)) * (11 - i); 39 } 40 resto = (soma * 10) % 11; 41 if ((resto === 10) || (resto === 11)) resto = 0; 42 if (resto !== parseInt(cpf.substring(9, 10))) return false; 43 44 soma = 0; 45 for (let i = 1; i <= 10; i++) { 46 soma += parseInt(cpf.substring(i - 1, i)) * (12 - i); 47 } 48 resto = (soma * 10) % 11; 49 if ((resto === 10) || (resto === 11)) resto = 0; 50 if (resto !== parseInt(cpf.substring(10, 11))) return false; 51 return true; 52 } 53 54}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.