@senior-agronegocio/angular-components 0.0.51 → 0.0.52
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 +23 -59
- package/bundles/senior-agronegocio-angular-components.umd.js.map +1 -1
- package/bundles/senior-agronegocio-angular-components.umd.min.js +2 -2
- package/bundles/senior-agronegocio-angular-components.umd.min.js.map +1 -1
- package/common/agro-platform-utils.class.d.ts +1 -1
- package/esm2015/common/agro-platform-utils.class.js +2 -3
- package/esm2015/common/agro-string-utils.class.js +23 -58
- package/esm5/common/agro-platform-utils.class.js +2 -3
- package/esm5/common/agro-string-utils.class.js +23 -58
- package/fesm2015/senior-agronegocio-angular-components.js +23 -59
- package/fesm2015/senior-agronegocio-angular-components.js.map +1 -1
- package/fesm5/senior-agronegocio-angular-components.js +23 -59
- package/fesm5/senior-agronegocio-angular-components.js.map +1 -1
- package/package.json +1 -1
|
@@ -2342,70 +2342,35 @@
|
|
|
2342
2342
|
return matches ? matches.length : exports.AGRO_NUMBERS.ZERO;
|
|
2343
2343
|
};
|
|
2344
2344
|
AgroStringUtils.validateCPF = function (cpf) {
|
|
2345
|
-
// Remover caracteres não numéricos
|
|
2346
2345
|
cpf = cpf.replace(/\D/g, "");
|
|
2347
|
-
|
|
2348
|
-
if (cpf.length !== exports.AGRO_NUMBERS.ELEVEN) {
|
|
2346
|
+
if (cpf.length !== 11 || /^(\d)\1{10}$/.test(cpf)) {
|
|
2349
2347
|
return false;
|
|
2350
2348
|
}
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
remainder = sum % exports.AGRO_NUMBERS.ELEVEN;
|
|
2362
|
-
if (remainder === exports.AGRO_NUMBERS.TEN || remainder === exports.AGRO_NUMBERS.ELEVEN) {
|
|
2363
|
-
remainder = exports.AGRO_NUMBERS.ZERO;
|
|
2364
|
-
}
|
|
2365
|
-
if (remainder !== parseInt(cpf[exports.AGRO_NUMBERS.NINE])) {
|
|
2366
|
-
return false;
|
|
2367
|
-
}
|
|
2368
|
-
// Calcular o segundo dígito verificador
|
|
2369
|
-
sum = exports.AGRO_NUMBERS.ZERO;
|
|
2370
|
-
for (var i = exports.AGRO_NUMBERS.ONE; i <= exports.AGRO_NUMBERS.TEN; i++) {
|
|
2371
|
-
sum += parseInt(cpf[i - exports.AGRO_NUMBERS.ONE]) * (exports.AGRO_NUMBERS.TWELVE - i);
|
|
2372
|
-
}
|
|
2373
|
-
remainder = sum % exports.AGRO_NUMBERS.ELEVEN;
|
|
2374
|
-
if (remainder === exports.AGRO_NUMBERS.TEN || remainder === exports.AGRO_NUMBERS.ELEVEN) {
|
|
2375
|
-
remainder = exports.AGRO_NUMBERS.ZERO;
|
|
2376
|
-
}
|
|
2377
|
-
if (remainder !== parseInt(cpf[exports.AGRO_NUMBERS.TEN])) {
|
|
2378
|
-
return false;
|
|
2379
|
-
}
|
|
2380
|
-
return true;
|
|
2349
|
+
var calcCheckDigit = function (length) {
|
|
2350
|
+
var sum = 0;
|
|
2351
|
+
for (var i = 0; i < length; i++) {
|
|
2352
|
+
sum += Number(cpf[i]) * (length + 1 - i);
|
|
2353
|
+
}
|
|
2354
|
+
var remainder = sum % 11;
|
|
2355
|
+
return remainder < 2 ? 0 : 11 - remainder;
|
|
2356
|
+
};
|
|
2357
|
+
return (calcCheckDigit(9) === Number(cpf[9]) &&
|
|
2358
|
+
calcCheckDigit(10) === Number(cpf[10]));
|
|
2381
2359
|
};
|
|
2382
2360
|
AgroStringUtils.validateCNPJ = function (cnpj) {
|
|
2383
|
-
// Remove todos os caracteres não numéricos
|
|
2384
2361
|
cnpj = cnpj.replace(/\D/g, "");
|
|
2385
|
-
|
|
2386
|
-
if (cnpj.length !== 14)
|
|
2387
|
-
return false;
|
|
2388
|
-
// Verifica se o CNPJ é uma sequência repetida (ex: 11111111111111, 22222222222222, etc.)
|
|
2389
|
-
if (/^(\d)\1{13}$/.test(cnpj))
|
|
2362
|
+
if (cnpj.length !== 14 || /^(\d)\1{13}$/.test(cnpj))
|
|
2390
2363
|
return false;
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
soma
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
var pesos2 = [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2];
|
|
2402
|
-
for (var i = 0; i < 13; i++) {
|
|
2403
|
-
soma += parseInt(cnpj.charAt(i)) * pesos2[i];
|
|
2404
|
-
}
|
|
2405
|
-
resto = soma % 11;
|
|
2406
|
-
var digito2 = resto < 2 ? 0 : 11 - resto;
|
|
2407
|
-
// Verifica se os dígitos verificadores são válidos
|
|
2408
|
-
return parseInt(cnpj.charAt(12)) === digito1 && parseInt(cnpj.charAt(13)) === digito2;
|
|
2364
|
+
var calcularDigito = function (length) {
|
|
2365
|
+
var pesos = length === 12
|
|
2366
|
+
? [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]
|
|
2367
|
+
: [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2];
|
|
2368
|
+
var soma = pesos.reduce(function (acc, peso, i) { return acc + Number(cnpj[i]) * peso; }, 0);
|
|
2369
|
+
var resto = soma % 11;
|
|
2370
|
+
return resto < 2 ? 0 : 11 - resto;
|
|
2371
|
+
};
|
|
2372
|
+
return (calcularDigito(12) === Number(cnpj[12]) &&
|
|
2373
|
+
calcularDigito(13) === Number(cnpj[13]));
|
|
2409
2374
|
};
|
|
2410
2375
|
/**
|
|
2411
2376
|
* Método para aplicar uma máscara em uma string. Considere a máscara com valores 9 para aplicação
|
|
@@ -2506,7 +2471,7 @@
|
|
|
2506
2471
|
/**
|
|
2507
2472
|
* Retorna o usuário logado
|
|
2508
2473
|
* Caso contrário, retorna uma instância de Error
|
|
2509
|
-
* @returns string ||
|
|
2474
|
+
* @returns string || null
|
|
2510
2475
|
*/
|
|
2511
2476
|
AgroPlatformUtils.getCurrentUserName = function () {
|
|
2512
2477
|
var _a;
|
|
@@ -2517,7 +2482,6 @@
|
|
|
2517
2482
|
return str;
|
|
2518
2483
|
}
|
|
2519
2484
|
}
|
|
2520
|
-
console.error('Cookie: "com.senior.token" não encontrado.');
|
|
2521
2485
|
return null;
|
|
2522
2486
|
};
|
|
2523
2487
|
/**
|