style: clean up code formatting and remove trailing whitespace
refactor: reorganize imports and fix type imports
This commit is contained in:
1 parent
d3704602fd
commit
47c04de6fe
232 files changed
+7140
-4798
No files matched your search
@@ -16,20 +16,20 @@ export function isValidCPF(cpf: string): boolean {
|
||||
// Valida primeiro dígito verificador
|
||||
let sum = 0;
|
||||
for (let i = 0; i < 9; i++) {
|
||||
sum += parseInt(cleaned.charAt(i)) * (10 - i);
|
||||
sum += parseInt(cleaned.charAt(i), 10) * (10 - i);
|
||||
}
|
||||
let remainder = (sum * 10) % 11;
|
||||
if (remainder === 10 || remainder === 11) remainder = 0;
|
||||
if (remainder !== parseInt(cleaned.charAt(9))) return false;
|
||||
if (remainder !== parseInt(cleaned.charAt(9), 10)) return false;
|
||||
|
||||
// Valida segundo dígito verificador
|
||||
sum = 0;
|
||||
for (let i = 0; i < 10; i++) {
|
||||
sum += parseInt(cleaned.charAt(i)) * (11 - i);
|
||||
sum += parseInt(cleaned.charAt(i), 10) * (11 - i);
|
||||
}
|
||||
remainder = (sum * 10) % 11;
|
||||
if (remainder === 10 || remainder === 11) remainder = 0;
|
||||
if (remainder !== parseInt(cleaned.charAt(10))) return false;
|
||||
if (remainder !== parseInt(cleaned.charAt(10), 10)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -48,21 +48,21 @@ export function isValidCNPJ(cnpj: string): boolean {
|
||||
const weights1 = [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2];
|
||||
let sum = 0;
|
||||
for (let i = 0; i < 12; i++) {
|
||||
sum += parseInt(cleaned.charAt(i)) * weights1[i];
|
||||
sum += parseInt(cleaned.charAt(i), 10) * weights1[i];
|
||||
}
|
||||
let remainder = sum % 11;
|
||||
const firstDigit = remainder < 2 ? 0 : 11 - remainder;
|
||||
if (firstDigit !== parseInt(cleaned.charAt(12))) return false;
|
||||
if (firstDigit !== parseInt(cleaned.charAt(12), 10)) return false;
|
||||
|
||||
// Valida segundo dígito verificador
|
||||
const weights2 = [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2];
|
||||
sum = 0;
|
||||
for (let i = 0; i < 13; i++) {
|
||||
sum += parseInt(cleaned.charAt(i)) * weights2[i];
|
||||
sum += parseInt(cleaned.charAt(i), 10) * weights2[i];
|
||||
}
|
||||
remainder = sum % 11;
|
||||
const secondDigit = remainder < 2 ? 0 : 11 - remainder;
|
||||
if (secondDigit !== parseInt(cleaned.charAt(13))) return false;
|
||||
if (secondDigit !== parseInt(cleaned.charAt(13), 10)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user