@senior-agronegocio/angular-components 0.0.76 → 0.0.77

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2290,42 +2290,21 @@ var AgroStringUtils = /** @class */ (function () {
2290
2290
  return matches ? matches.length : AGRO_NUMBERS.ZERO;
2291
2291
  };
2292
2292
  AgroStringUtils.validateCPF = function (cpf) {
2293
- // Remover caracteres não numéricos
2294
- cpf = cpf.replace(/\D/g, "");
2295
- // Verificar se o CPF tem 11 dígitos
2296
- if (cpf.length !== AGRO_NUMBERS.ELEVEN) {
2293
+ cpf = cpf.replace(/\D/g, '');
2294
+ if (cpf.length !== 11 || /^(\d)\1+$/.test(cpf)) {
2297
2295
  return false;
2298
2296
  }
2299
- // Verificar se todos os dígitos são iguais (caso contrário, é um sinal de CPF inválido)
2300
- if (/^(\d)\1{10}$/.test(cpf)) {
2301
- return false;
2302
- }
2303
- // Calcular o primeiro dígito verificador
2304
- var sum = AGRO_NUMBERS.ZERO;
2305
- var remainder;
2306
- for (var i = AGRO_NUMBERS.ONE; i <= AGRO_NUMBERS.NINE; i++) {
2307
- sum += parseInt(cpf[i - AGRO_NUMBERS.ONE]) * (AGRO_NUMBERS.ELEVEN - i);
2308
- }
2309
- remainder = sum % AGRO_NUMBERS.ELEVEN;
2310
- if (remainder === AGRO_NUMBERS.TEN || remainder === AGRO_NUMBERS.ELEVEN) {
2311
- remainder = AGRO_NUMBERS.ZERO;
2312
- }
2313
- if (remainder !== parseInt(cpf[AGRO_NUMBERS.NINE])) {
2314
- return false;
2315
- }
2316
- // Calcular o segundo dígito verificador
2317
- sum = AGRO_NUMBERS.ZERO;
2318
- for (var i = AGRO_NUMBERS.ONE; i <= AGRO_NUMBERS.TEN; i++) {
2319
- sum += parseInt(cpf[i - AGRO_NUMBERS.ONE]) * (AGRO_NUMBERS.TWELVE - i);
2320
- }
2321
- remainder = sum % AGRO_NUMBERS.ELEVEN;
2322
- if (remainder === AGRO_NUMBERS.TEN || remainder === AGRO_NUMBERS.ELEVEN) {
2323
- remainder = AGRO_NUMBERS.ZERO;
2324
- }
2325
- if (remainder !== parseInt(cpf[AGRO_NUMBERS.TEN])) {
2326
- return false;
2327
- }
2328
- return true;
2297
+ var calcVerifier = function (cpf, length) {
2298
+ var sum = 0;
2299
+ for (var i = 0; i < length; i++) {
2300
+ sum += parseInt(cpf[i]) * (length + 1 - i);
2301
+ }
2302
+ var result = sum % 11;
2303
+ return result < 2 ? 0 : 11 - result;
2304
+ };
2305
+ var digit1 = calcVerifier(cpf, 9);
2306
+ var digit2 = calcVerifier(cpf, 10);
2307
+ return digit1 === parseInt(cpf[9]) && digit2 === parseInt(cpf[10]);
2329
2308
  };
2330
2309
  AgroStringUtils.validateCNPJ = function (cnpj) {
2331
2310
  // Remove todos os caracteres não numéricos