@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
|
@@ -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
|
-
|
|
2294
|
-
cpf
|
|
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
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
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
|