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
|
@@ -236,6 +236,7 @@ var CountryMasks;
|
|
|
236
236
|
CountryMasks["RUT2"] = "00000000-A";
|
|
237
237
|
CountryMasks["RFC1"] = "AAAA000000AA0";
|
|
238
238
|
CountryMasks["RFC2"] = "AAA000000AA0";
|
|
239
|
+
CountryMasks["EIN"] = "00-0000000";
|
|
239
240
|
})(CountryMasks || (CountryMasks = {}));
|
|
240
241
|
|
|
241
242
|
var statics = /*#__PURE__*/Object.freeze({
|
|
@@ -281,6 +282,11 @@ class MonkeyEcxUtils {
|
|
|
281
282
|
CPF: CountryMasks.RFC1,
|
|
282
283
|
CNPJ: CountryMasks.RFC2,
|
|
283
284
|
'': `${CountryMasks.RFC1}||${CountryMasks.RFC2}`
|
|
285
|
+
},
|
|
286
|
+
US: {
|
|
287
|
+
CPF: CountryMasks.EIN,
|
|
288
|
+
CNPJ: CountryMasks.EIN,
|
|
289
|
+
'': CountryMasks.EIN
|
|
284
290
|
}
|
|
285
291
|
}[country.toUpperCase()]?.[type];
|
|
286
292
|
}
|
|
@@ -309,7 +315,8 @@ class MonkeyEcxUtils {
|
|
|
309
315
|
return `${formated}`;
|
|
310
316
|
}
|
|
311
317
|
if (country === 'us') {
|
|
312
|
-
|
|
318
|
+
formated = doc.replace(/^(\d{2})(\d{7})$/, '$1-$2');
|
|
319
|
+
return `${formated}`;
|
|
313
320
|
}
|
|
314
321
|
if (doc.length === 14) {
|
|
315
322
|
const cleaned = doc.replace(/[^A-Za-z0-9]/g, '').toUpperCase();
|
|
@@ -565,6 +572,100 @@ class MonkeyEcxUtils {
|
|
|
565
572
|
}
|
|
566
573
|
return false;
|
|
567
574
|
}
|
|
575
|
+
static isValidEIN(ein) {
|
|
576
|
+
const cleanedEIN = ein?.replace(/\D/g, '') || '';
|
|
577
|
+
if (cleanedEIN.length !== 9) {
|
|
578
|
+
return false;
|
|
579
|
+
}
|
|
580
|
+
const validPrefixes = [
|
|
581
|
+
'10',
|
|
582
|
+
'12',
|
|
583
|
+
'60',
|
|
584
|
+
'67',
|
|
585
|
+
'50',
|
|
586
|
+
'53',
|
|
587
|
+
'01',
|
|
588
|
+
'02',
|
|
589
|
+
'03',
|
|
590
|
+
'04',
|
|
591
|
+
'05',
|
|
592
|
+
'06',
|
|
593
|
+
'11',
|
|
594
|
+
'13',
|
|
595
|
+
'14',
|
|
596
|
+
'16',
|
|
597
|
+
'21',
|
|
598
|
+
'22',
|
|
599
|
+
'23',
|
|
600
|
+
'25',
|
|
601
|
+
'34',
|
|
602
|
+
'51',
|
|
603
|
+
'52',
|
|
604
|
+
'54',
|
|
605
|
+
'55',
|
|
606
|
+
'56',
|
|
607
|
+
'57',
|
|
608
|
+
'58',
|
|
609
|
+
'59',
|
|
610
|
+
'65',
|
|
611
|
+
'30',
|
|
612
|
+
'32',
|
|
613
|
+
'35',
|
|
614
|
+
'36',
|
|
615
|
+
'37',
|
|
616
|
+
'38',
|
|
617
|
+
'61',
|
|
618
|
+
'15',
|
|
619
|
+
'24',
|
|
620
|
+
'20',
|
|
621
|
+
'26',
|
|
622
|
+
'27',
|
|
623
|
+
'45',
|
|
624
|
+
'46',
|
|
625
|
+
'47',
|
|
626
|
+
'81',
|
|
627
|
+
'82',
|
|
628
|
+
'83',
|
|
629
|
+
'84',
|
|
630
|
+
'85',
|
|
631
|
+
'40',
|
|
632
|
+
'44',
|
|
633
|
+
'94',
|
|
634
|
+
'95',
|
|
635
|
+
'80',
|
|
636
|
+
'90',
|
|
637
|
+
'33',
|
|
638
|
+
'39',
|
|
639
|
+
'41',
|
|
640
|
+
'42',
|
|
641
|
+
'43',
|
|
642
|
+
'46',
|
|
643
|
+
'48',
|
|
644
|
+
'62',
|
|
645
|
+
'63',
|
|
646
|
+
'64',
|
|
647
|
+
'66',
|
|
648
|
+
'68',
|
|
649
|
+
'71',
|
|
650
|
+
'72',
|
|
651
|
+
'73',
|
|
652
|
+
'74',
|
|
653
|
+
'75',
|
|
654
|
+
'76',
|
|
655
|
+
'77',
|
|
656
|
+
'86',
|
|
657
|
+
'87',
|
|
658
|
+
'88',
|
|
659
|
+
'91',
|
|
660
|
+
'92',
|
|
661
|
+
'93',
|
|
662
|
+
'98',
|
|
663
|
+
'99',
|
|
664
|
+
'31'
|
|
665
|
+
];
|
|
666
|
+
const prefix = cleanedEIN.substring(0, 2);
|
|
667
|
+
return validPrefixes.indexOf(prefix) !== -1;
|
|
668
|
+
}
|
|
568
669
|
static isValidUrl(txt) {
|
|
569
670
|
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
671
|
return regex.test(txt);
|
|
@@ -573,7 +674,8 @@ class MonkeyEcxUtils {
|
|
|
573
674
|
const length = {
|
|
574
675
|
br: 8,
|
|
575
676
|
cl: 7,
|
|
576
|
-
mx: 5
|
|
677
|
+
mx: 5,
|
|
678
|
+
us: 5
|
|
577
679
|
}[country || 'br'];
|
|
578
680
|
return `${this.handleOnlyNumbers(zipCode)}`.length === length;
|
|
579
681
|
}
|
|
@@ -1285,6 +1387,20 @@ class DocumentRutValidator {
|
|
|
1285
1387
|
return null;
|
|
1286
1388
|
}
|
|
1287
1389
|
}
|
|
1390
|
+
class DocumentEINValidator {
|
|
1391
|
+
static do(control) {
|
|
1392
|
+
if (!control.parent || !control)
|
|
1393
|
+
return null;
|
|
1394
|
+
if (control && control.value) {
|
|
1395
|
+
if (!MonkeyEcxUtils.isValidEIN(control.value)) {
|
|
1396
|
+
return {
|
|
1397
|
+
invalidEin: true
|
|
1398
|
+
};
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
return null;
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1288
1404
|
class DocumentRFCValidator {
|
|
1289
1405
|
static do(control) {
|
|
1290
1406
|
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,
|
|
@@ -1619,6 +1736,13 @@ function documentValidator(control, country) {
|
|
|
1619
1736
|
};
|
|
1620
1737
|
}
|
|
1621
1738
|
}
|
|
1739
|
+
else if (country === 'US') {
|
|
1740
|
+
if (!MonkeyEcxUtils.isValidEIN(control.value)) {
|
|
1741
|
+
return {
|
|
1742
|
+
invalidCpfCnpj: true
|
|
1743
|
+
};
|
|
1744
|
+
}
|
|
1745
|
+
}
|
|
1622
1746
|
return null;
|
|
1623
1747
|
}
|
|
1624
1748
|
function minYearsValidator(param, control) {
|
|
@@ -1699,6 +1823,9 @@ function documentValidatorByType(type, control) {
|
|
|
1699
1823
|
else if (type === 'RFC') {
|
|
1700
1824
|
valid = MonkeyEcxUtils.isValidRFC(control.value);
|
|
1701
1825
|
}
|
|
1826
|
+
else if (type === 'EIN') {
|
|
1827
|
+
valid = MonkeyEcxUtils.isValidEIN(control.value);
|
|
1828
|
+
}
|
|
1702
1829
|
if (!valid) {
|
|
1703
1830
|
return {
|
|
1704
1831
|
[`invalid${MonkeyEcxUtils.capitalize(type.toLowerCase())}`]: true
|
|
@@ -1770,6 +1897,9 @@ class Validators {
|
|
|
1770
1897
|
static documentMX(control) {
|
|
1771
1898
|
return documentValidator(control, 'MX');
|
|
1772
1899
|
}
|
|
1900
|
+
static documentUS(control) {
|
|
1901
|
+
return documentValidator(control, 'US');
|
|
1902
|
+
}
|
|
1773
1903
|
static date(control) {
|
|
1774
1904
|
return dateValidator(control);
|
|
1775
1905
|
}
|