@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
|
@@ -2142,70 +2142,35 @@ class AgroStringUtils {
|
|
|
2142
2142
|
return matches ? matches.length : AGRO_NUMBERS.ZERO;
|
|
2143
2143
|
}
|
|
2144
2144
|
static validateCPF(cpf) {
|
|
2145
|
-
// Remover caracteres não numéricos
|
|
2146
2145
|
cpf = cpf.replace(/\D/g, "");
|
|
2147
|
-
|
|
2148
|
-
if (cpf.length !== AGRO_NUMBERS.ELEVEN) {
|
|
2146
|
+
if (cpf.length !== 11 || /^(\d)\1{10}$/.test(cpf)) {
|
|
2149
2147
|
return false;
|
|
2150
2148
|
}
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
remainder = sum % AGRO_NUMBERS.ELEVEN;
|
|
2162
|
-
if (remainder === AGRO_NUMBERS.TEN || remainder === AGRO_NUMBERS.ELEVEN) {
|
|
2163
|
-
remainder = AGRO_NUMBERS.ZERO;
|
|
2164
|
-
}
|
|
2165
|
-
if (remainder !== parseInt(cpf[AGRO_NUMBERS.NINE])) {
|
|
2166
|
-
return false;
|
|
2167
|
-
}
|
|
2168
|
-
// Calcular o segundo dígito verificador
|
|
2169
|
-
sum = AGRO_NUMBERS.ZERO;
|
|
2170
|
-
for (let i = AGRO_NUMBERS.ONE; i <= AGRO_NUMBERS.TEN; i++) {
|
|
2171
|
-
sum += parseInt(cpf[i - AGRO_NUMBERS.ONE]) * (AGRO_NUMBERS.TWELVE - i);
|
|
2172
|
-
}
|
|
2173
|
-
remainder = sum % AGRO_NUMBERS.ELEVEN;
|
|
2174
|
-
if (remainder === AGRO_NUMBERS.TEN || remainder === AGRO_NUMBERS.ELEVEN) {
|
|
2175
|
-
remainder = AGRO_NUMBERS.ZERO;
|
|
2176
|
-
}
|
|
2177
|
-
if (remainder !== parseInt(cpf[AGRO_NUMBERS.TEN])) {
|
|
2178
|
-
return false;
|
|
2179
|
-
}
|
|
2180
|
-
return true;
|
|
2149
|
+
const calcCheckDigit = (length) => {
|
|
2150
|
+
let sum = 0;
|
|
2151
|
+
for (let i = 0; i < length; i++) {
|
|
2152
|
+
sum += Number(cpf[i]) * (length + 1 - i);
|
|
2153
|
+
}
|
|
2154
|
+
let remainder = sum % 11;
|
|
2155
|
+
return remainder < 2 ? 0 : 11 - remainder;
|
|
2156
|
+
};
|
|
2157
|
+
return (calcCheckDigit(9) === Number(cpf[9]) &&
|
|
2158
|
+
calcCheckDigit(10) === Number(cpf[10]));
|
|
2181
2159
|
}
|
|
2182
2160
|
static validateCNPJ(cnpj) {
|
|
2183
|
-
// Remove todos os caracteres não numéricos
|
|
2184
2161
|
cnpj = cnpj.replace(/\D/g, "");
|
|
2185
|
-
|
|
2186
|
-
if (cnpj.length !== 14)
|
|
2187
|
-
return false;
|
|
2188
|
-
// Verifica se o CNPJ é uma sequência repetida (ex: 11111111111111, 22222222222222, etc.)
|
|
2189
|
-
if (/^(\d)\1{13}$/.test(cnpj))
|
|
2162
|
+
if (cnpj.length !== 14 || /^(\d)\1{13}$/.test(cnpj))
|
|
2190
2163
|
return false;
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
soma
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
let pesos2 = [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2];
|
|
2202
|
-
for (let i = 0; i < 13; i++) {
|
|
2203
|
-
soma += parseInt(cnpj.charAt(i)) * pesos2[i];
|
|
2204
|
-
}
|
|
2205
|
-
resto = soma % 11;
|
|
2206
|
-
let digito2 = resto < 2 ? 0 : 11 - resto;
|
|
2207
|
-
// Verifica se os dígitos verificadores são válidos
|
|
2208
|
-
return parseInt(cnpj.charAt(12)) === digito1 && parseInt(cnpj.charAt(13)) === digito2;
|
|
2164
|
+
const calcularDigito = (length) => {
|
|
2165
|
+
const pesos = length === 12
|
|
2166
|
+
? [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]
|
|
2167
|
+
: [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2];
|
|
2168
|
+
const soma = pesos.reduce((acc, peso, i) => acc + Number(cnpj[i]) * peso, 0);
|
|
2169
|
+
const resto = soma % 11;
|
|
2170
|
+
return resto < 2 ? 0 : 11 - resto;
|
|
2171
|
+
};
|
|
2172
|
+
return (calcularDigito(12) === Number(cnpj[12]) &&
|
|
2173
|
+
calcularDigito(13) === Number(cnpj[13]));
|
|
2209
2174
|
}
|
|
2210
2175
|
/**
|
|
2211
2176
|
* Método para aplicar uma máscara em uma string. Considere a máscara com valores 9 para aplicação
|
|
@@ -2292,7 +2257,7 @@ class AgroPlatformUtils {
|
|
|
2292
2257
|
/**
|
|
2293
2258
|
* Retorna o usuário logado
|
|
2294
2259
|
* Caso contrário, retorna uma instância de Error
|
|
2295
|
-
* @returns string ||
|
|
2260
|
+
* @returns string || null
|
|
2296
2261
|
*/
|
|
2297
2262
|
static getCurrentUserName() {
|
|
2298
2263
|
var _a;
|
|
@@ -2303,7 +2268,6 @@ class AgroPlatformUtils {
|
|
|
2303
2268
|
return str;
|
|
2304
2269
|
}
|
|
2305
2270
|
}
|
|
2306
|
-
console.error('Cookie: "com.senior.token" não encontrado.');
|
|
2307
2271
|
return null;
|
|
2308
2272
|
}
|
|
2309
2273
|
/**
|