monkey-front-core 0.0.615 → 0.0.617
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/utils.mjs +99 -3
- package/esm2020/lib/core/utils/validate-utils.mjs +15 -1
- package/esm2020/lib/core/utils/validators.mjs +14 -1
- package/esm2020/lib/monkey-front-core.module.mjs +3 -3
- package/esm2020/lib/store/reducers/monkeyecx-storage.reducer.mjs +2 -2
- package/esm2020/lib/store/selectors/monkeyecx-storage.selector.mjs +2 -2
- package/fesm2015/monkey-front-core.mjs +131 -7
- package/fesm2015/monkey-front-core.mjs.map +1 -1
- package/fesm2020/monkey-front-core.mjs +131 -7
- package/fesm2020/monkey-front-core.mjs.map +1 -1
- package/lib/core/utils/utils.d.ts +1 -0
- package/lib/core/utils/validate-utils.d.ts +5 -0
- package/lib/core/utils/validators.d.ts +1 -0
- package/lib/store/reducers/monkeyecx-storage.reducer.d.ts +1 -1
- package/monkey-front-core-0.0.617.tgz +0 -0
- package/package.json +1 -1
- package/monkey-front-core-0.0.615.tgz +0 -0
|
@@ -309,7 +309,8 @@ class MonkeyEcxUtils {
|
|
|
309
309
|
return `${formated}`;
|
|
310
310
|
}
|
|
311
311
|
if (country === 'us') {
|
|
312
|
-
|
|
312
|
+
formated = doc.replace(/^(\d{2})(\d{7})$/, '$1-$2');
|
|
313
|
+
return `${formated}`;
|
|
313
314
|
}
|
|
314
315
|
if (doc.length === 14) {
|
|
315
316
|
const cleaned = doc.replace(/[^A-Za-z0-9]/g, '').toUpperCase();
|
|
@@ -565,6 +566,100 @@ class MonkeyEcxUtils {
|
|
|
565
566
|
}
|
|
566
567
|
return false;
|
|
567
568
|
}
|
|
569
|
+
static isValidEIN(ein) {
|
|
570
|
+
const cleanedEIN = ein?.replace(/\D/g, '') || '';
|
|
571
|
+
if (cleanedEIN.length !== 9) {
|
|
572
|
+
return false;
|
|
573
|
+
}
|
|
574
|
+
const validPrefixes = [
|
|
575
|
+
'10',
|
|
576
|
+
'12',
|
|
577
|
+
'60',
|
|
578
|
+
'67',
|
|
579
|
+
'50',
|
|
580
|
+
'53',
|
|
581
|
+
'01',
|
|
582
|
+
'02',
|
|
583
|
+
'03',
|
|
584
|
+
'04',
|
|
585
|
+
'05',
|
|
586
|
+
'06',
|
|
587
|
+
'11',
|
|
588
|
+
'13',
|
|
589
|
+
'14',
|
|
590
|
+
'16',
|
|
591
|
+
'21',
|
|
592
|
+
'22',
|
|
593
|
+
'23',
|
|
594
|
+
'25',
|
|
595
|
+
'34',
|
|
596
|
+
'51',
|
|
597
|
+
'52',
|
|
598
|
+
'54',
|
|
599
|
+
'55',
|
|
600
|
+
'56',
|
|
601
|
+
'57',
|
|
602
|
+
'58',
|
|
603
|
+
'59',
|
|
604
|
+
'65',
|
|
605
|
+
'30',
|
|
606
|
+
'32',
|
|
607
|
+
'35',
|
|
608
|
+
'36',
|
|
609
|
+
'37',
|
|
610
|
+
'38',
|
|
611
|
+
'61',
|
|
612
|
+
'15',
|
|
613
|
+
'24',
|
|
614
|
+
'20',
|
|
615
|
+
'26',
|
|
616
|
+
'27',
|
|
617
|
+
'45',
|
|
618
|
+
'46',
|
|
619
|
+
'47',
|
|
620
|
+
'81',
|
|
621
|
+
'82',
|
|
622
|
+
'83',
|
|
623
|
+
'84',
|
|
624
|
+
'85',
|
|
625
|
+
'40',
|
|
626
|
+
'44',
|
|
627
|
+
'94',
|
|
628
|
+
'95',
|
|
629
|
+
'80',
|
|
630
|
+
'90',
|
|
631
|
+
'33',
|
|
632
|
+
'39',
|
|
633
|
+
'41',
|
|
634
|
+
'42',
|
|
635
|
+
'43',
|
|
636
|
+
'46',
|
|
637
|
+
'48',
|
|
638
|
+
'62',
|
|
639
|
+
'63',
|
|
640
|
+
'64',
|
|
641
|
+
'66',
|
|
642
|
+
'68',
|
|
643
|
+
'71',
|
|
644
|
+
'72',
|
|
645
|
+
'73',
|
|
646
|
+
'74',
|
|
647
|
+
'75',
|
|
648
|
+
'76',
|
|
649
|
+
'77',
|
|
650
|
+
'86',
|
|
651
|
+
'87',
|
|
652
|
+
'88',
|
|
653
|
+
'91',
|
|
654
|
+
'92',
|
|
655
|
+
'93',
|
|
656
|
+
'98',
|
|
657
|
+
'99',
|
|
658
|
+
'31'
|
|
659
|
+
];
|
|
660
|
+
const prefix = cleanedEIN.substring(0, 2);
|
|
661
|
+
return validPrefixes.indexOf(prefix) !== -1;
|
|
662
|
+
}
|
|
568
663
|
static isValidUrl(txt) {
|
|
569
664
|
const regex = /(https?:\/\/(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9])(:?\d*)\/?([a-z_\\/0-9\-#.]*)\??([a-z_\\/0-9\-#=&]*)/g;
|
|
570
665
|
return regex.test(txt);
|
|
@@ -573,7 +668,8 @@ class MonkeyEcxUtils {
|
|
|
573
668
|
const length = {
|
|
574
669
|
br: 8,
|
|
575
670
|
cl: 7,
|
|
576
|
-
mx: 5
|
|
671
|
+
mx: 5,
|
|
672
|
+
us: 5
|
|
577
673
|
}[country || 'br'];
|
|
578
674
|
return `${this.handleOnlyNumbers(zipCode)}`.length === length;
|
|
579
675
|
}
|
|
@@ -1285,6 +1381,20 @@ class DocumentRutValidator {
|
|
|
1285
1381
|
return null;
|
|
1286
1382
|
}
|
|
1287
1383
|
}
|
|
1384
|
+
class DocumentEINValidator {
|
|
1385
|
+
static do(control) {
|
|
1386
|
+
if (!control.parent || !control)
|
|
1387
|
+
return null;
|
|
1388
|
+
if (control && control.value) {
|
|
1389
|
+
if (!MonkeyEcxUtils.isValidEIN(control.value)) {
|
|
1390
|
+
return {
|
|
1391
|
+
invalidEin: true
|
|
1392
|
+
};
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
return null;
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1288
1398
|
class DocumentRFCValidator {
|
|
1289
1399
|
static do(control) {
|
|
1290
1400
|
if (!control.parent || !control)
|
|
@@ -1462,6 +1572,7 @@ var validateUtils = /*#__PURE__*/Object.freeze({
|
|
|
1462
1572
|
DocumentValidator: DocumentValidator,
|
|
1463
1573
|
AlphanumericDocumentValidator: AlphanumericDocumentValidator,
|
|
1464
1574
|
DocumentRutValidator: DocumentRutValidator,
|
|
1575
|
+
DocumentEINValidator: DocumentEINValidator,
|
|
1465
1576
|
DocumentRFCValidator: DocumentRFCValidator,
|
|
1466
1577
|
ZipCodeValidator: ZipCodeValidator,
|
|
1467
1578
|
ComboValidator: ComboValidator,
|
|
@@ -1619,6 +1730,13 @@ function documentValidator(control, country) {
|
|
|
1619
1730
|
};
|
|
1620
1731
|
}
|
|
1621
1732
|
}
|
|
1733
|
+
else if (country === 'US') {
|
|
1734
|
+
if (!MonkeyEcxUtils.isValidEIN(control.value)) {
|
|
1735
|
+
return {
|
|
1736
|
+
invalidCpfCnpj: true
|
|
1737
|
+
};
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1622
1740
|
return null;
|
|
1623
1741
|
}
|
|
1624
1742
|
function minYearsValidator(param, control) {
|
|
@@ -1699,6 +1817,9 @@ function documentValidatorByType(type, control) {
|
|
|
1699
1817
|
else if (type === 'RFC') {
|
|
1700
1818
|
valid = MonkeyEcxUtils.isValidRFC(control.value);
|
|
1701
1819
|
}
|
|
1820
|
+
else if (type === 'EIN') {
|
|
1821
|
+
valid = MonkeyEcxUtils.isValidEIN(control.value);
|
|
1822
|
+
}
|
|
1702
1823
|
if (!valid) {
|
|
1703
1824
|
return {
|
|
1704
1825
|
[`invalid${MonkeyEcxUtils.capitalize(type.toLowerCase())}`]: true
|
|
@@ -1770,6 +1891,9 @@ class Validators {
|
|
|
1770
1891
|
static documentMX(control) {
|
|
1771
1892
|
return documentValidator(control, 'MX');
|
|
1772
1893
|
}
|
|
1894
|
+
static documentUS(control) {
|
|
1895
|
+
return documentValidator(control, 'US');
|
|
1896
|
+
}
|
|
1773
1897
|
static date(control) {
|
|
1774
1898
|
return dateValidator(control);
|
|
1775
1899
|
}
|
|
@@ -3104,7 +3228,7 @@ var monkeyecxSeeder_reducer = /*#__PURE__*/Object.freeze({
|
|
|
3104
3228
|
seederReducer: seederReducer
|
|
3105
3229
|
});
|
|
3106
3230
|
|
|
3107
|
-
const
|
|
3231
|
+
const featureName = 'mecx-core-storage';
|
|
3108
3232
|
const adapter = createEntityAdapter({
|
|
3109
3233
|
selectId: (item) => {
|
|
3110
3234
|
return item.username;
|
|
@@ -3143,7 +3267,7 @@ const { selectAll: selectAll$1, selectEntities, selectIds, selectTotal } = adapt
|
|
|
3143
3267
|
|
|
3144
3268
|
var monkeyecxStorage_reducer = /*#__PURE__*/Object.freeze({
|
|
3145
3269
|
__proto__: null,
|
|
3146
|
-
|
|
3270
|
+
featureName: featureName,
|
|
3147
3271
|
adapter: adapter,
|
|
3148
3272
|
initialState: initialState,
|
|
3149
3273
|
reducer: reducer,
|
|
@@ -3159,7 +3283,7 @@ var index$2 = /*#__PURE__*/Object.freeze({
|
|
|
3159
3283
|
fromMonkeyecxStorage: monkeyecxStorage_reducer
|
|
3160
3284
|
});
|
|
3161
3285
|
|
|
3162
|
-
const selectState = createFeatureSelector(
|
|
3286
|
+
const selectState = createFeatureSelector(featureName);
|
|
3163
3287
|
const selectAll = createSelector(selectState, selectAll$1);
|
|
3164
3288
|
const select = (props) => {
|
|
3165
3289
|
return createSelector(selectAll, (entities) => {
|
|
@@ -7385,7 +7509,7 @@ MonkeyFrontCoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", v
|
|
|
7385
7509
|
MonkeyStyleGuideModule,
|
|
7386
7510
|
ServiceWorkerModule.register('ngsw-worker.js'),
|
|
7387
7511
|
ClosedToMaintenanceModule,
|
|
7388
|
-
StoreModule.forFeature(
|
|
7512
|
+
StoreModule.forFeature(featureName, reducer),
|
|
7389
7513
|
VersionChangedModule,
|
|
7390
7514
|
AlertsModule,
|
|
7391
7515
|
CurrencyConfigModule
|
|
@@ -7403,7 +7527,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
|
|
|
7403
7527
|
MonkeyStyleGuideModule,
|
|
7404
7528
|
ServiceWorkerModule.register('ngsw-worker.js'),
|
|
7405
7529
|
ClosedToMaintenanceModule,
|
|
7406
|
-
StoreModule.forFeature(
|
|
7530
|
+
StoreModule.forFeature(featureName, reducer),
|
|
7407
7531
|
VersionChangedModule,
|
|
7408
7532
|
AlertsModule,
|
|
7409
7533
|
CurrencyConfigModule
|