monkey-front-core 0.0.611 → 0.0.612
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/esm2020/lib/core/utils/CNPJ.mjs +51 -0
- package/esm2020/lib/core/utils/CPF.mjs +52 -0
- package/esm2020/lib/core/utils/index.mjs +3 -1
- package/esm2020/lib/core/utils/utils.mjs +16 -1
- package/esm2020/lib/core/utils/validate-utils.mjs +15 -1
- package/fesm2015/monkey-front-core.mjs +132 -1
- package/fesm2015/monkey-front-core.mjs.map +1 -1
- package/fesm2020/monkey-front-core.mjs +132 -1
- package/fesm2020/monkey-front-core.mjs.map +1 -1
- package/lib/core/utils/CNPJ.d.ts +13 -0
- package/lib/core/utils/CPF.d.ts +11 -0
- package/lib/core/utils/index.d.ts +2 -0
- package/lib/core/utils/utils.d.ts +1 -0
- package/lib/core/utils/validate-utils.d.ts +5 -0
- package/monkey-front-core-0.0.612.tgz +0 -0
- package/package.json +3 -3
- package/monkey-front-core-0.0.611.tgz +0 -0
|
@@ -87,6 +87,109 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
|
|
|
87
87
|
}]
|
|
88
88
|
}] });
|
|
89
89
|
|
|
90
|
+
/* eslint-disable no-plusplus */
|
|
91
|
+
class CNPJValidator {
|
|
92
|
+
static removeMask(document) {
|
|
93
|
+
return document.replace(this.maskCharactersRegex, '');
|
|
94
|
+
}
|
|
95
|
+
static calculateCheckDigits(document) {
|
|
96
|
+
if (!this.invalidCharactersRegex.test(document)) {
|
|
97
|
+
const unmaskedCnpj = this.removeMask(document);
|
|
98
|
+
if (this.baseRegex.test(unmaskedCnpj) &&
|
|
99
|
+
unmaskedCnpj !== this.zeroCnpj.substring(0, this.baseLength)) {
|
|
100
|
+
let sumDV1 = 0;
|
|
101
|
+
let sumDV2 = 0;
|
|
102
|
+
for (let i = 0; i < this.baseLength; i++) {
|
|
103
|
+
const digitAscii = unmaskedCnpj.charCodeAt(i) - this.zeroCharCode;
|
|
104
|
+
sumDV1 += digitAscii * this.checkDigitWeights[i + 1];
|
|
105
|
+
sumDV2 += digitAscii * this.checkDigitWeights[i];
|
|
106
|
+
}
|
|
107
|
+
const dv1 = sumDV1 % 11 < 2 ? 0 : 11 - (sumDV1 % 11);
|
|
108
|
+
sumDV2 += dv1 * this.checkDigitWeights[this.baseLength];
|
|
109
|
+
const dv2 = sumDV2 % 11 < 2 ? 0 : 11 - (sumDV2 % 11);
|
|
110
|
+
return `${dv1}${dv2}`;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
throw new Error('');
|
|
114
|
+
}
|
|
115
|
+
static isValid(document) {
|
|
116
|
+
try {
|
|
117
|
+
if (!this.invalidCharactersRegex.test(document)) {
|
|
118
|
+
const unmasked = this.removeMask(document);
|
|
119
|
+
if (this.fullRegex.test(unmasked) && unmasked !== this.zeroCnpj) {
|
|
120
|
+
const providedCheckDigits = unmasked.substring(this.baseLength);
|
|
121
|
+
const calculatedCheckDigits = this.calculateCheckDigits(unmasked.substring(0, this.baseLength));
|
|
122
|
+
return providedCheckDigits === calculatedCheckDigits;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
catch (e) {
|
|
127
|
+
// not to do
|
|
128
|
+
}
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
CNPJValidator.baseLength = 12;
|
|
133
|
+
CNPJValidator.baseRegex = /^([A-Z\d]){12}$/;
|
|
134
|
+
CNPJValidator.fullRegex = /^([A-Z\d]){12}(\d){2}$/;
|
|
135
|
+
CNPJValidator.maskCharactersRegex = /[./-]/g;
|
|
136
|
+
CNPJValidator.invalidCharactersRegex = /[^A-Z\d./-]/i;
|
|
137
|
+
CNPJValidator.zeroCharCode = '0'.charCodeAt(0);
|
|
138
|
+
CNPJValidator.checkDigitWeights = [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2];
|
|
139
|
+
CNPJValidator.zeroCnpj = '00000000000000';
|
|
140
|
+
|
|
141
|
+
/* eslint-disable no-plusplus */
|
|
142
|
+
class CPFValidator {
|
|
143
|
+
static removeMask(document) {
|
|
144
|
+
return document.replace(this.maskCharactersRegex, '');
|
|
145
|
+
}
|
|
146
|
+
static calculateCheckDigits(document) {
|
|
147
|
+
if (!this.invalidCharactersRegex.test(document)) {
|
|
148
|
+
const unmasked = this.removeMask(document);
|
|
149
|
+
if (this.baseRegex.test(unmasked) &&
|
|
150
|
+
unmasked !== this.zeroCpf.substring(0, this.baseLength)) {
|
|
151
|
+
const weightsDV1 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0];
|
|
152
|
+
const weightsDV2 = [11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0];
|
|
153
|
+
let sumDV1 = 0;
|
|
154
|
+
let sumDV2 = 0;
|
|
155
|
+
for (let i = 0; i < document.length; i++) {
|
|
156
|
+
sumDV1 += Number(document[i]) * weightsDV1[i];
|
|
157
|
+
}
|
|
158
|
+
const dv1 = sumDV1 % 11 <= 1 ? 0 : 11 - (sumDV1 % 11);
|
|
159
|
+
document = `${document}${dv1}`;
|
|
160
|
+
for (let i = 0; i < document.length; i++) {
|
|
161
|
+
sumDV2 += Number(document[i]) * weightsDV2[i];
|
|
162
|
+
}
|
|
163
|
+
const dv2 = sumDV2 % 11 <= 1 ? 0 : 11 - (sumDV2 % 11);
|
|
164
|
+
return `${dv1}${dv2}`;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
throw new Error('');
|
|
168
|
+
}
|
|
169
|
+
static isValid(document) {
|
|
170
|
+
try {
|
|
171
|
+
if (!this.invalidCharactersRegex.test(document)) {
|
|
172
|
+
const unmasked = this.removeMask(document);
|
|
173
|
+
if (this.fullRegex.test(unmasked) && unmasked !== this.zeroCpf) {
|
|
174
|
+
const providedCheckDigits = unmasked.substring(this.baseLength);
|
|
175
|
+
const calculatedCheckDigits = this.calculateCheckDigits(unmasked.substring(0, this.baseLength));
|
|
176
|
+
return providedCheckDigits === calculatedCheckDigits;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
catch (e) {
|
|
181
|
+
// not to do
|
|
182
|
+
}
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
CPFValidator.baseLength = 9;
|
|
187
|
+
CPFValidator.baseRegex = /^([A-Z\d]){9}$/;
|
|
188
|
+
CPFValidator.maskCharactersRegex = /[./-]/g;
|
|
189
|
+
CPFValidator.invalidCharactersRegex = /[^A-Z\d./-]/i;
|
|
190
|
+
CPFValidator.fullRegex = /^([\d]){9}(\d){2}$/;
|
|
191
|
+
CPFValidator.zeroCpf = '00000000000';
|
|
192
|
+
|
|
90
193
|
/* eslint-disable no-unused-vars */
|
|
91
194
|
/* eslint-disable no-shadow */
|
|
92
195
|
var MonkeyEcxQueueEvents;
|
|
@@ -264,6 +367,19 @@ class MonkeyEcxUtils {
|
|
|
264
367
|
}
|
|
265
368
|
return false;
|
|
266
369
|
}
|
|
370
|
+
static isCPFAlphanumericCNPJValid(document) {
|
|
371
|
+
document = document.replace(/[./-]/g, '');
|
|
372
|
+
const handled = document.replace(new RegExp(document.charAt(0), 'g'), '');
|
|
373
|
+
if (!handled)
|
|
374
|
+
return false;
|
|
375
|
+
if (document.length === 11) {
|
|
376
|
+
return CPFValidator.isValid(document);
|
|
377
|
+
}
|
|
378
|
+
if (document.length === 14 || /0{14}/.test(document)) {
|
|
379
|
+
return CNPJValidator.isValid(document);
|
|
380
|
+
}
|
|
381
|
+
return false;
|
|
382
|
+
}
|
|
267
383
|
static isValidRUT(document) {
|
|
268
384
|
if (!document || document.trim().length < 3)
|
|
269
385
|
return false;
|
|
@@ -1139,6 +1255,20 @@ class DocumentValidator {
|
|
|
1139
1255
|
return null;
|
|
1140
1256
|
}
|
|
1141
1257
|
}
|
|
1258
|
+
class AlphanumericDocumentValidator {
|
|
1259
|
+
static do(control) {
|
|
1260
|
+
if (!control.parent || !control)
|
|
1261
|
+
return null;
|
|
1262
|
+
if (control && control.value) {
|
|
1263
|
+
if (!MonkeyEcxUtils.isCPFAlphanumericCNPJValid(control.value)) {
|
|
1264
|
+
return {
|
|
1265
|
+
invalidCpfCnpj: true
|
|
1266
|
+
};
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
return null;
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1142
1272
|
class DocumentRutValidator {
|
|
1143
1273
|
static do(control) {
|
|
1144
1274
|
if (!control.parent || !control)
|
|
@@ -1328,6 +1458,7 @@ var validateUtils = /*#__PURE__*/Object.freeze({
|
|
|
1328
1458
|
__proto__: null,
|
|
1329
1459
|
DateValidator: DateValidator,
|
|
1330
1460
|
DocumentValidator: DocumentValidator,
|
|
1461
|
+
AlphanumericDocumentValidator: AlphanumericDocumentValidator,
|
|
1331
1462
|
DocumentRutValidator: DocumentRutValidator,
|
|
1332
1463
|
DocumentRFCValidator: DocumentRFCValidator,
|
|
1333
1464
|
ZipCodeValidator: ZipCodeValidator,
|
|
@@ -7286,5 +7417,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
|
|
|
7286
7417
|
* Generated bundle index. Do not edit.
|
|
7287
7418
|
*/
|
|
7288
7419
|
|
|
7289
|
-
export { AlertsComponent, AlertsModule, ClosedToMaintenanceComponent, ClosedToMaintenanceModule, CurrencyConfigComponent, CurrencyConfigModule, decoratorsUtils as DecoratorsUtils, GTMService, LService, Link, MECX_ALPHA, MECX_BETA, MECX_DATE_FORMAT, MECX_ENV, MECX_LANG, MECX_TIMEZONEOFFSET, MonkeyEcxAlertsService, MonkeyEcxAuthGuard, MonkeyEcxAuthGuardByRole, MonkeyEcxAuthGuardCompany, MonkeyEcxAuthGuardLogin, MonkeyEcxAuthenticationService, MonkeyEcxBlobSecurePipe, MonkeyEcxCommonsActions, MonkeyEcxCommonsResolveBaseService, MonkeyEcxCommonsResolveService, MonkeyEcxCommonsSelectors, MonkeyEcxCommonsService, MonkeyEcxCommonsStoreBaseService, MonkeyEcxCommonsStoreService, MonkeyEcxConfigModule, MonkeyEcxConfigService, MonkeyEcxCookieStorageService, MonkeyEcxCoreCharts, MonkeyEcxCoreClearDecorators, MonkeyEcxCoreLog, MonkeyEcxCoreService, MonkeyEcxCoreServiceConstructor, MonkeyEcxCoreServicePaged, MonkeyEcxCoreServiceQueue, MonkeyEcxCurrencyCodePipe, MonkeyEcxCurrencyConfigService, MonkeyEcxDirectivesModule, MonkeyEcxDiscoveryParamsService, MonkeyEcxDisplayFirstNamePipe, MonkeyEcxDisplayInitialsPipe, MonkeyEcxDisplaySupportPhone, MonkeyEcxDragDropDirective, MonkeyEcxErrorConfigService, MonkeyEcxErrorHandlingModule, MonkeyEcxErrorHandlingService, MonkeyEcxFeatureByProgramDirective, MonkeyEcxFeatureDirective, MonkeyEcxFeatureToggleService, MonkeyEcxFormatAddressPipe, MonkeyEcxFormatBeaufityJSONPipe, MonkeyEcxFormatCurrency, MonkeyEcxFormatCurrencyPipe, MonkeyEcxFormatDateGroupPipe, MonkeyEcxFormatDatePipe, MonkeyEcxFormatDateTimelapsePipe, MonkeyEcxFormatDateUnixTimelapsePipe, MonkeyEcxFormatDocumentPipe, MonkeyEcxFormatDocumentTypePipe, MonkeyEcxFormatNumberPipe, MonkeyEcxFormatPhonePipe, MonkeyEcxFormatSizePipe, MonkeyEcxFormatTaxPipe, MonkeyEcxFormatUpper, MonkeyEcxFormatValue, MonkeyEcxFormatZipCodePipe, MonkeyEcxHandlingService, MonkeyEcxHttpConfigErrorInterceptor, MonkeyEcxHttpConfigHeaderInterceptor, MonkeyEcxHttpConfigInterceptorModule, MonkeyEcxHttpConfigLoadingInProgressInterceptor, MonkeyEcxHttpConfigQueueInterceptor, MonkeyEcxHttpErrorHandlingService, MonkeyEcxLinksModel, MonkeyEcxLoadingDirective, MonkeyEcxLoggedHandlingService, MonkeyEcxLogs, MonkeyEcxLogsConfigService, MonkeyEcxMaintenanceConfigService, MonkeyEcxModel, MonkeyEcxOnlyAlphaNumericDirective, MonkeyEcxOnlyNumbersDirective, MonkeyEcxOthersErrorsHandlingService, MonkeyEcxPaginationService, MonkeyEcxPipesModule, MonkeyEcxPopoverDirective, MonkeyEcxPopoverOptionsDirective, MonkeyEcxProgressBarComponent, MonkeyEcxProgressBarModule, MonkeyEcxProgressBarService, MonkeyEcxRequestDownloadHandlingService, MonkeyEcxRequestDownloadedHandlingService, MonkeyEcxRequestPagedHandling, MonkeyEcxRequestQueueHandlingService, MonkeyEcxRequestQueueModalHandlingService, MonkeyEcxRequestScheduleService, MonkeyEcxSecurityConsoleConfigService, MonkeyEcxSecurityDirective, MonkeyEcxService, MonkeyEcxServiceDownload, MonkeyEcxServiceUpload, MonkeyEcxServiceWorkerConfigService, MonkeyEcxSpecificationSearch, MonkeyEcxTextTruncatePipe, MonkeyEcxTokenStorageService, MonkeyEcxTooltipDirective, MonkeyEcxTruncateQtdPipe, MonkeyEcxUtils, MonkeyEcxi18nConfigService, MonkeyFrontCoreModule, OpSearch, POPOVER_OPTIONS, statics as Statics, validateUtils as ValidateUtils, Validators, VersionChangedComponent, VersionChangedModule, comboValidator, containsNumber, dateRangeValidator, dateStartEndValidator, dateValidator, differentFromZero, documentValidator, documentValidatorByType, emailValidator, minYearsValidator, passwordConfirmValidator, registerValidator, requiredWithTrimValidator, index as store, trueValidator, urlValidator, validateFullName, valueGreaterThanZero, zipCodeValidator };
|
|
7420
|
+
export { AlertsComponent, AlertsModule, CNPJValidator, CPFValidator, ClosedToMaintenanceComponent, ClosedToMaintenanceModule, CurrencyConfigComponent, CurrencyConfigModule, decoratorsUtils as DecoratorsUtils, GTMService, LService, Link, MECX_ALPHA, MECX_BETA, MECX_DATE_FORMAT, MECX_ENV, MECX_LANG, MECX_TIMEZONEOFFSET, MonkeyEcxAlertsService, MonkeyEcxAuthGuard, MonkeyEcxAuthGuardByRole, MonkeyEcxAuthGuardCompany, MonkeyEcxAuthGuardLogin, MonkeyEcxAuthenticationService, MonkeyEcxBlobSecurePipe, MonkeyEcxCommonsActions, MonkeyEcxCommonsResolveBaseService, MonkeyEcxCommonsResolveService, MonkeyEcxCommonsSelectors, MonkeyEcxCommonsService, MonkeyEcxCommonsStoreBaseService, MonkeyEcxCommonsStoreService, MonkeyEcxConfigModule, MonkeyEcxConfigService, MonkeyEcxCookieStorageService, MonkeyEcxCoreCharts, MonkeyEcxCoreClearDecorators, MonkeyEcxCoreLog, MonkeyEcxCoreService, MonkeyEcxCoreServiceConstructor, MonkeyEcxCoreServicePaged, MonkeyEcxCoreServiceQueue, MonkeyEcxCurrencyCodePipe, MonkeyEcxCurrencyConfigService, MonkeyEcxDirectivesModule, MonkeyEcxDiscoveryParamsService, MonkeyEcxDisplayFirstNamePipe, MonkeyEcxDisplayInitialsPipe, MonkeyEcxDisplaySupportPhone, MonkeyEcxDragDropDirective, MonkeyEcxErrorConfigService, MonkeyEcxErrorHandlingModule, MonkeyEcxErrorHandlingService, MonkeyEcxFeatureByProgramDirective, MonkeyEcxFeatureDirective, MonkeyEcxFeatureToggleService, MonkeyEcxFormatAddressPipe, MonkeyEcxFormatBeaufityJSONPipe, MonkeyEcxFormatCurrency, MonkeyEcxFormatCurrencyPipe, MonkeyEcxFormatDateGroupPipe, MonkeyEcxFormatDatePipe, MonkeyEcxFormatDateTimelapsePipe, MonkeyEcxFormatDateUnixTimelapsePipe, MonkeyEcxFormatDocumentPipe, MonkeyEcxFormatDocumentTypePipe, MonkeyEcxFormatNumberPipe, MonkeyEcxFormatPhonePipe, MonkeyEcxFormatSizePipe, MonkeyEcxFormatTaxPipe, MonkeyEcxFormatUpper, MonkeyEcxFormatValue, MonkeyEcxFormatZipCodePipe, MonkeyEcxHandlingService, MonkeyEcxHttpConfigErrorInterceptor, MonkeyEcxHttpConfigHeaderInterceptor, MonkeyEcxHttpConfigInterceptorModule, MonkeyEcxHttpConfigLoadingInProgressInterceptor, MonkeyEcxHttpConfigQueueInterceptor, MonkeyEcxHttpErrorHandlingService, MonkeyEcxLinksModel, MonkeyEcxLoadingDirective, MonkeyEcxLoggedHandlingService, MonkeyEcxLogs, MonkeyEcxLogsConfigService, MonkeyEcxMaintenanceConfigService, MonkeyEcxModel, MonkeyEcxOnlyAlphaNumericDirective, MonkeyEcxOnlyNumbersDirective, MonkeyEcxOthersErrorsHandlingService, MonkeyEcxPaginationService, MonkeyEcxPipesModule, MonkeyEcxPopoverDirective, MonkeyEcxPopoverOptionsDirective, MonkeyEcxProgressBarComponent, MonkeyEcxProgressBarModule, MonkeyEcxProgressBarService, MonkeyEcxRequestDownloadHandlingService, MonkeyEcxRequestDownloadedHandlingService, MonkeyEcxRequestPagedHandling, MonkeyEcxRequestQueueHandlingService, MonkeyEcxRequestQueueModalHandlingService, MonkeyEcxRequestScheduleService, MonkeyEcxSecurityConsoleConfigService, MonkeyEcxSecurityDirective, MonkeyEcxService, MonkeyEcxServiceDownload, MonkeyEcxServiceUpload, MonkeyEcxServiceWorkerConfigService, MonkeyEcxSpecificationSearch, MonkeyEcxTextTruncatePipe, MonkeyEcxTokenStorageService, MonkeyEcxTooltipDirective, MonkeyEcxTruncateQtdPipe, MonkeyEcxUtils, MonkeyEcxi18nConfigService, MonkeyFrontCoreModule, OpSearch, POPOVER_OPTIONS, statics as Statics, validateUtils as ValidateUtils, Validators, VersionChangedComponent, VersionChangedModule, comboValidator, containsNumber, dateRangeValidator, dateStartEndValidator, dateValidator, differentFromZero, documentValidator, documentValidatorByType, emailValidator, minYearsValidator, passwordConfirmValidator, registerValidator, requiredWithTrimValidator, index as store, trueValidator, urlValidator, validateFullName, valueGreaterThanZero, zipCodeValidator };
|
|
7290
7421
|
//# sourceMappingURL=monkey-front-core.mjs.map
|