monkey-front-core 0.0.616 → 0.0.618
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/statics.mjs +2 -1
- package/esm2020/lib/core/utils/utils.mjs +104 -3
- package/esm2020/lib/core/utils/validate-utils.mjs +15 -1
- package/esm2020/lib/core/utils/validators.mjs +14 -1
- package/fesm2015/monkey-front-core.mjs +132 -2
- package/fesm2015/monkey-front-core.mjs.map +1 -1
- package/fesm2020/monkey-front-core.mjs +132 -2
- package/fesm2020/monkey-front-core.mjs.map +1 -1
- package/lib/core/utils/statics.d.ts +2 -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/monkey-front-core-0.0.618.tgz +0 -0
- package/package.json +1 -1
- package/monkey-front-core-0.0.616.tgz +0 -0
|
@@ -237,6 +237,7 @@ var CountryMasks;
|
|
|
237
237
|
CountryMasks["RUT2"] = "00000000-A";
|
|
238
238
|
CountryMasks["RFC1"] = "AAAA000000AA0";
|
|
239
239
|
CountryMasks["RFC2"] = "AAA000000AA0";
|
|
240
|
+
CountryMasks["EIN"] = "00-0000000";
|
|
240
241
|
})(CountryMasks || (CountryMasks = {}));
|
|
241
242
|
|
|
242
243
|
var statics = /*#__PURE__*/Object.freeze({
|
|
@@ -283,6 +284,11 @@ class MonkeyEcxUtils {
|
|
|
283
284
|
CPF: CountryMasks.RFC1,
|
|
284
285
|
CNPJ: CountryMasks.RFC2,
|
|
285
286
|
'': `${CountryMasks.RFC1}||${CountryMasks.RFC2}`
|
|
287
|
+
},
|
|
288
|
+
US: {
|
|
289
|
+
CPF: CountryMasks.EIN,
|
|
290
|
+
CNPJ: CountryMasks.EIN,
|
|
291
|
+
'': CountryMasks.EIN
|
|
286
292
|
}
|
|
287
293
|
}[country.toUpperCase()]) === null || _a === void 0 ? void 0 : _a[type];
|
|
288
294
|
}
|
|
@@ -312,7 +318,8 @@ class MonkeyEcxUtils {
|
|
|
312
318
|
return `${formated}`;
|
|
313
319
|
}
|
|
314
320
|
if (country === 'us') {
|
|
315
|
-
|
|
321
|
+
formated = doc.replace(/^(\d{2})(\d{7})$/, '$1-$2');
|
|
322
|
+
return `${formated}`;
|
|
316
323
|
}
|
|
317
324
|
if (doc.length === 14) {
|
|
318
325
|
const cleaned = doc.replace(/[^A-Za-z0-9]/g, '').toUpperCase();
|
|
@@ -569,6 +576,100 @@ class MonkeyEcxUtils {
|
|
|
569
576
|
}
|
|
570
577
|
return false;
|
|
571
578
|
}
|
|
579
|
+
static isValidEIN(ein) {
|
|
580
|
+
const cleanedEIN = (ein === null || ein === void 0 ? void 0 : ein.replace(/\D/g, '')) || '';
|
|
581
|
+
if (cleanedEIN.length !== 9) {
|
|
582
|
+
return false;
|
|
583
|
+
}
|
|
584
|
+
const validPrefixes = [
|
|
585
|
+
'10',
|
|
586
|
+
'12',
|
|
587
|
+
'60',
|
|
588
|
+
'67',
|
|
589
|
+
'50',
|
|
590
|
+
'53',
|
|
591
|
+
'01',
|
|
592
|
+
'02',
|
|
593
|
+
'03',
|
|
594
|
+
'04',
|
|
595
|
+
'05',
|
|
596
|
+
'06',
|
|
597
|
+
'11',
|
|
598
|
+
'13',
|
|
599
|
+
'14',
|
|
600
|
+
'16',
|
|
601
|
+
'21',
|
|
602
|
+
'22',
|
|
603
|
+
'23',
|
|
604
|
+
'25',
|
|
605
|
+
'34',
|
|
606
|
+
'51',
|
|
607
|
+
'52',
|
|
608
|
+
'54',
|
|
609
|
+
'55',
|
|
610
|
+
'56',
|
|
611
|
+
'57',
|
|
612
|
+
'58',
|
|
613
|
+
'59',
|
|
614
|
+
'65',
|
|
615
|
+
'30',
|
|
616
|
+
'32',
|
|
617
|
+
'35',
|
|
618
|
+
'36',
|
|
619
|
+
'37',
|
|
620
|
+
'38',
|
|
621
|
+
'61',
|
|
622
|
+
'15',
|
|
623
|
+
'24',
|
|
624
|
+
'20',
|
|
625
|
+
'26',
|
|
626
|
+
'27',
|
|
627
|
+
'45',
|
|
628
|
+
'46',
|
|
629
|
+
'47',
|
|
630
|
+
'81',
|
|
631
|
+
'82',
|
|
632
|
+
'83',
|
|
633
|
+
'84',
|
|
634
|
+
'85',
|
|
635
|
+
'40',
|
|
636
|
+
'44',
|
|
637
|
+
'94',
|
|
638
|
+
'95',
|
|
639
|
+
'80',
|
|
640
|
+
'90',
|
|
641
|
+
'33',
|
|
642
|
+
'39',
|
|
643
|
+
'41',
|
|
644
|
+
'42',
|
|
645
|
+
'43',
|
|
646
|
+
'46',
|
|
647
|
+
'48',
|
|
648
|
+
'62',
|
|
649
|
+
'63',
|
|
650
|
+
'64',
|
|
651
|
+
'66',
|
|
652
|
+
'68',
|
|
653
|
+
'71',
|
|
654
|
+
'72',
|
|
655
|
+
'73',
|
|
656
|
+
'74',
|
|
657
|
+
'75',
|
|
658
|
+
'76',
|
|
659
|
+
'77',
|
|
660
|
+
'86',
|
|
661
|
+
'87',
|
|
662
|
+
'88',
|
|
663
|
+
'91',
|
|
664
|
+
'92',
|
|
665
|
+
'93',
|
|
666
|
+
'98',
|
|
667
|
+
'99',
|
|
668
|
+
'31'
|
|
669
|
+
];
|
|
670
|
+
const prefix = cleanedEIN.substring(0, 2);
|
|
671
|
+
return validPrefixes.indexOf(prefix) !== -1;
|
|
672
|
+
}
|
|
572
673
|
static isValidUrl(txt) {
|
|
573
674
|
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;
|
|
574
675
|
return regex.test(txt);
|
|
@@ -577,7 +678,8 @@ class MonkeyEcxUtils {
|
|
|
577
678
|
const length = {
|
|
578
679
|
br: 8,
|
|
579
680
|
cl: 7,
|
|
580
|
-
mx: 5
|
|
681
|
+
mx: 5,
|
|
682
|
+
us: 5
|
|
581
683
|
}[country || 'br'];
|
|
582
684
|
return `${this.handleOnlyNumbers(zipCode)}`.length === length;
|
|
583
685
|
}
|
|
@@ -1281,6 +1383,20 @@ class DocumentRutValidator {
|
|
|
1281
1383
|
return null;
|
|
1282
1384
|
}
|
|
1283
1385
|
}
|
|
1386
|
+
class DocumentEINValidator {
|
|
1387
|
+
static do(control) {
|
|
1388
|
+
if (!control.parent || !control)
|
|
1389
|
+
return null;
|
|
1390
|
+
if (control && control.value) {
|
|
1391
|
+
if (!MonkeyEcxUtils.isValidEIN(control.value)) {
|
|
1392
|
+
return {
|
|
1393
|
+
invalidEin: true
|
|
1394
|
+
};
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1397
|
+
return null;
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1284
1400
|
class DocumentRFCValidator {
|
|
1285
1401
|
static do(control) {
|
|
1286
1402
|
if (!control.parent || !control)
|
|
@@ -1462,6 +1578,7 @@ var validateUtils = /*#__PURE__*/Object.freeze({
|
|
|
1462
1578
|
DocumentValidator: DocumentValidator,
|
|
1463
1579
|
AlphanumericDocumentValidator: AlphanumericDocumentValidator,
|
|
1464
1580
|
DocumentRutValidator: DocumentRutValidator,
|
|
1581
|
+
DocumentEINValidator: DocumentEINValidator,
|
|
1465
1582
|
DocumentRFCValidator: DocumentRFCValidator,
|
|
1466
1583
|
ZipCodeValidator: ZipCodeValidator,
|
|
1467
1584
|
ComboValidator: ComboValidator,
|
|
@@ -1622,6 +1739,13 @@ function documentValidator(control, country) {
|
|
|
1622
1739
|
};
|
|
1623
1740
|
}
|
|
1624
1741
|
}
|
|
1742
|
+
else if (country === 'US') {
|
|
1743
|
+
if (!MonkeyEcxUtils.isValidEIN(control.value)) {
|
|
1744
|
+
return {
|
|
1745
|
+
invalidCpfCnpj: true
|
|
1746
|
+
};
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1625
1749
|
return null;
|
|
1626
1750
|
}
|
|
1627
1751
|
function minYearsValidator(param, control) {
|
|
@@ -1702,6 +1826,9 @@ function documentValidatorByType(type, control) {
|
|
|
1702
1826
|
else if (type === 'RFC') {
|
|
1703
1827
|
valid = MonkeyEcxUtils.isValidRFC(control.value);
|
|
1704
1828
|
}
|
|
1829
|
+
else if (type === 'EIN') {
|
|
1830
|
+
valid = MonkeyEcxUtils.isValidEIN(control.value);
|
|
1831
|
+
}
|
|
1705
1832
|
if (!valid) {
|
|
1706
1833
|
return {
|
|
1707
1834
|
[`invalid${MonkeyEcxUtils.capitalize(type.toLowerCase())}`]: true
|
|
@@ -1775,6 +1902,9 @@ class Validators {
|
|
|
1775
1902
|
static documentMX(control) {
|
|
1776
1903
|
return documentValidator(control, 'MX');
|
|
1777
1904
|
}
|
|
1905
|
+
static documentUS(control) {
|
|
1906
|
+
return documentValidator(control, 'US');
|
|
1907
|
+
}
|
|
1778
1908
|
static date(control) {
|
|
1779
1909
|
return dateValidator(control);
|
|
1780
1910
|
}
|