@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.
- package/bundles/senior-agronegocio-angular-components.umd.js +13 -34
- package/bundles/senior-agronegocio-angular-components.umd.js.map +1 -1
- package/bundles/senior-agronegocio-angular-components.umd.min.js +1 -1
- package/bundles/senior-agronegocio-angular-components.umd.min.js.map +1 -1
- package/esm2015/common/agro-string-utils.class.js +14 -35
- package/esm5/common/agro-string-utils.class.js +14 -35
- package/fesm2015/senior-agronegocio-angular-components.js +13 -34
- package/fesm2015/senior-agronegocio-angular-components.js.map +1 -1
- package/fesm5/senior-agronegocio-angular-components.js +13 -34
- package/fesm5/senior-agronegocio-angular-components.js.map +1 -1
- package/package.json +1 -1
|
@@ -2466,42 +2466,21 @@
|
|
|
2466
2466
|
return matches ? matches.length : exports.AGRO_NUMBERS.ZERO;
|
|
2467
2467
|
};
|
|
2468
2468
|
AgroStringUtils.validateCPF = function (cpf) {
|
|
2469
|
-
|
|
2470
|
-
cpf
|
|
2471
|
-
// Verificar se o CPF tem 11 dígitos
|
|
2472
|
-
if (cpf.length !== exports.AGRO_NUMBERS.ELEVEN) {
|
|
2469
|
+
cpf = cpf.replace(/\D/g, '');
|
|
2470
|
+
if (cpf.length !== 11 || /^(\d)\1+$/.test(cpf)) {
|
|
2473
2471
|
return false;
|
|
2474
2472
|
}
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
if (remainder === exports.AGRO_NUMBERS.TEN || remainder === exports.AGRO_NUMBERS.ELEVEN) {
|
|
2487
|
-
remainder = exports.AGRO_NUMBERS.ZERO;
|
|
2488
|
-
}
|
|
2489
|
-
if (remainder !== parseInt(cpf[exports.AGRO_NUMBERS.NINE])) {
|
|
2490
|
-
return false;
|
|
2491
|
-
}
|
|
2492
|
-
// Calcular o segundo dígito verificador
|
|
2493
|
-
sum = exports.AGRO_NUMBERS.ZERO;
|
|
2494
|
-
for (var i = exports.AGRO_NUMBERS.ONE; i <= exports.AGRO_NUMBERS.TEN; i++) {
|
|
2495
|
-
sum += parseInt(cpf[i - exports.AGRO_NUMBERS.ONE]) * (exports.AGRO_NUMBERS.TWELVE - i);
|
|
2496
|
-
}
|
|
2497
|
-
remainder = sum % exports.AGRO_NUMBERS.ELEVEN;
|
|
2498
|
-
if (remainder === exports.AGRO_NUMBERS.TEN || remainder === exports.AGRO_NUMBERS.ELEVEN) {
|
|
2499
|
-
remainder = exports.AGRO_NUMBERS.ZERO;
|
|
2500
|
-
}
|
|
2501
|
-
if (remainder !== parseInt(cpf[exports.AGRO_NUMBERS.TEN])) {
|
|
2502
|
-
return false;
|
|
2503
|
-
}
|
|
2504
|
-
return true;
|
|
2473
|
+
var calcVerifier = function (cpf, length) {
|
|
2474
|
+
var sum = 0;
|
|
2475
|
+
for (var i = 0; i < length; i++) {
|
|
2476
|
+
sum += parseInt(cpf[i]) * (length + 1 - i);
|
|
2477
|
+
}
|
|
2478
|
+
var result = sum % 11;
|
|
2479
|
+
return result < 2 ? 0 : 11 - result;
|
|
2480
|
+
};
|
|
2481
|
+
var digit1 = calcVerifier(cpf, 9);
|
|
2482
|
+
var digit2 = calcVerifier(cpf, 10);
|
|
2483
|
+
return digit1 === parseInt(cpf[9]) && digit2 === parseInt(cpf[10]);
|
|
2505
2484
|
};
|
|
2506
2485
|
AgroStringUtils.validateCNPJ = function (cnpj) {
|
|
2507
2486
|
// Remove todos os caracteres não numéricos
|