monkey-front-core 0.0.611 → 0.0.613
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/statics.mjs +2 -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 +133 -1
- package/fesm2015/monkey-front-core.mjs.map +1 -1
- package/fesm2020/monkey-front-core.mjs +133 -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/statics.d.ts +1 -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.613.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;
|
|
@@ -128,6 +231,7 @@ var CountryMasks;
|
|
|
128
231
|
(function (CountryMasks) {
|
|
129
232
|
CountryMasks["CPF"] = "000.000.000-00";
|
|
130
233
|
CountryMasks["CNPJ"] = "00.000.000/0000-00";
|
|
234
|
+
CountryMasks["ALPHANUMERIC_CNPJ"] = "AA.AAA.AAA/AAAA-00";
|
|
131
235
|
CountryMasks["RUT1"] = "0000000-A";
|
|
132
236
|
CountryMasks["RUT2"] = "00000000-A";
|
|
133
237
|
CountryMasks["RFC1"] = "AAAA000000AA0";
|
|
@@ -264,6 +368,19 @@ class MonkeyEcxUtils {
|
|
|
264
368
|
}
|
|
265
369
|
return false;
|
|
266
370
|
}
|
|
371
|
+
static isCPFAlphanumericCNPJValid(document) {
|
|
372
|
+
document = document.replace(/[./-]/g, '');
|
|
373
|
+
const handled = document.replace(new RegExp(document.charAt(0), 'g'), '');
|
|
374
|
+
if (!handled)
|
|
375
|
+
return false;
|
|
376
|
+
if (document.length === 11) {
|
|
377
|
+
return CPFValidator.isValid(document);
|
|
378
|
+
}
|
|
379
|
+
if (document.length === 14 || /0{14}/.test(document)) {
|
|
380
|
+
return CNPJValidator.isValid(document);
|
|
381
|
+
}
|
|
382
|
+
return false;
|
|
383
|
+
}
|
|
267
384
|
static isValidRUT(document) {
|
|
268
385
|
if (!document || document.trim().length < 3)
|
|
269
386
|
return false;
|
|
@@ -1139,6 +1256,20 @@ class DocumentValidator {
|
|
|
1139
1256
|
return null;
|
|
1140
1257
|
}
|
|
1141
1258
|
}
|
|
1259
|
+
class AlphanumericDocumentValidator {
|
|
1260
|
+
static do(control) {
|
|
1261
|
+
if (!control.parent || !control)
|
|
1262
|
+
return null;
|
|
1263
|
+
if (control && control.value) {
|
|
1264
|
+
if (!MonkeyEcxUtils.isCPFAlphanumericCNPJValid(control.value)) {
|
|
1265
|
+
return {
|
|
1266
|
+
invalidCpfCnpj: true
|
|
1267
|
+
};
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
return null;
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1142
1273
|
class DocumentRutValidator {
|
|
1143
1274
|
static do(control) {
|
|
1144
1275
|
if (!control.parent || !control)
|
|
@@ -1328,6 +1459,7 @@ var validateUtils = /*#__PURE__*/Object.freeze({
|
|
|
1328
1459
|
__proto__: null,
|
|
1329
1460
|
DateValidator: DateValidator,
|
|
1330
1461
|
DocumentValidator: DocumentValidator,
|
|
1462
|
+
AlphanumericDocumentValidator: AlphanumericDocumentValidator,
|
|
1331
1463
|
DocumentRutValidator: DocumentRutValidator,
|
|
1332
1464
|
DocumentRFCValidator: DocumentRFCValidator,
|
|
1333
1465
|
ZipCodeValidator: ZipCodeValidator,
|
|
@@ -7286,5 +7418,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
|
|
|
7286
7418
|
* Generated bundle index. Do not edit.
|
|
7287
7419
|
*/
|
|
7288
7420
|
|
|
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 };
|
|
7421
|
+
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
7422
|
//# sourceMappingURL=monkey-front-core.mjs.map
|