monkey-front-core 0.0.259 → 0.0.261
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 +4 -3
- package/esm2020/lib/core/utils/validate-utils.mjs +1 -1
- package/esm2020/lib/core/utils/validators.mjs +21 -16
- package/fesm2015/monkey-front-core.mjs +23 -17
- package/fesm2015/monkey-front-core.mjs.map +1 -1
- package/fesm2020/monkey-front-core.mjs +23 -17
- package/fesm2020/monkey-front-core.mjs.map +1 -1
- package/lib/core/utils/utils.d.ts +1 -1
- package/lib/core/utils/validators.d.ts +2 -1
- package/monkey-front-core-0.0.261.tgz +0 -0
- package/package.json +1 -1
- package/monkey-front-core-0.0.259.tgz +0 -0
|
@@ -196,8 +196,9 @@ class MonkeyEcxUtils {
|
|
|
196
196
|
const regex = new RegExp(/^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)+[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,10}(:[0-9]{1,5})?(\/.*)?$/gm);
|
|
197
197
|
return regex.test(txt);
|
|
198
198
|
}
|
|
199
|
-
static isValidZipCode(zipCode) {
|
|
200
|
-
|
|
199
|
+
static isValidZipCode(zipCode, country) {
|
|
200
|
+
const length = (country === 'cl') ? 7 : 8;
|
|
201
|
+
return `${this.handleOnlyNumbers(zipCode)}`.length === length;
|
|
201
202
|
}
|
|
202
203
|
static getRandomString(len, charSet) {
|
|
203
204
|
charSet = charSet || 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
@@ -848,7 +849,7 @@ function emailValidator(control) {
|
|
|
848
849
|
if (test)
|
|
849
850
|
return null;
|
|
850
851
|
return {
|
|
851
|
-
email: true
|
|
852
|
+
email: true
|
|
852
853
|
};
|
|
853
854
|
}
|
|
854
855
|
function dateRangeValidator(control) {
|
|
@@ -860,7 +861,7 @@ function dateRangeValidator(control) {
|
|
|
860
861
|
(!MonkeyEcxUtils.persistNullEmptyUndefined(dates?.startDate) ||
|
|
861
862
|
!MonkeyEcxUtils.persistNullEmptyUndefined(dates?.endDate))) {
|
|
862
863
|
return {
|
|
863
|
-
dateRange: true
|
|
864
|
+
dateRange: true
|
|
864
865
|
};
|
|
865
866
|
}
|
|
866
867
|
return null;
|
|
@@ -871,7 +872,7 @@ function registerValidator(control, type) {
|
|
|
871
872
|
}
|
|
872
873
|
if (control && control.value !== `#MONKEY${type}`.toUpperCase()) {
|
|
873
874
|
return {
|
|
874
|
-
invalidUnlockRegister: true
|
|
875
|
+
invalidUnlockRegister: true
|
|
875
876
|
};
|
|
876
877
|
}
|
|
877
878
|
return null;
|
|
@@ -895,7 +896,7 @@ function dateStartEndValidator(control) {
|
|
|
895
896
|
return null;
|
|
896
897
|
if (dateStart > dateEnd) {
|
|
897
898
|
return {
|
|
898
|
-
dateStartMustBeLessThanAnd: true
|
|
899
|
+
dateStartMustBeLessThanAnd: true
|
|
899
900
|
};
|
|
900
901
|
}
|
|
901
902
|
return null;
|
|
@@ -905,7 +906,7 @@ function urlValidator(control) {
|
|
|
905
906
|
return null;
|
|
906
907
|
if (!MonkeyEcxUtils.isValidUrl(control.value)) {
|
|
907
908
|
return {
|
|
908
|
-
url: true
|
|
909
|
+
url: true
|
|
909
910
|
};
|
|
910
911
|
}
|
|
911
912
|
return null;
|
|
@@ -921,7 +922,7 @@ function passwordConfirmValidator(control) {
|
|
|
921
922
|
if (password === passwordConfirm)
|
|
922
923
|
return null;
|
|
923
924
|
return {
|
|
924
|
-
passwordsNotMatching: true
|
|
925
|
+
passwordsNotMatching: true
|
|
925
926
|
};
|
|
926
927
|
}
|
|
927
928
|
function trueValidator(control) {
|
|
@@ -930,7 +931,7 @@ function trueValidator(control) {
|
|
|
930
931
|
if (control && control.value !== false)
|
|
931
932
|
return null;
|
|
932
933
|
return {
|
|
933
|
-
invalidTrue: true
|
|
934
|
+
invalidTrue: true
|
|
934
935
|
};
|
|
935
936
|
}
|
|
936
937
|
function comboValidator(control) {
|
|
@@ -939,16 +940,16 @@ function comboValidator(control) {
|
|
|
939
940
|
if (control && control.value !== '0')
|
|
940
941
|
return null;
|
|
941
942
|
return {
|
|
942
|
-
invalidCombo: true
|
|
943
|
+
invalidCombo: true
|
|
943
944
|
};
|
|
944
945
|
}
|
|
945
|
-
function zipCodeValidator(control) {
|
|
946
|
+
function zipCodeValidator(control, country) {
|
|
946
947
|
if (!control.parent || !control || isEmptyInputValue(control.value))
|
|
947
948
|
return null;
|
|
948
949
|
if (control && control.value) {
|
|
949
|
-
if (!MonkeyEcxUtils.isValidZipCode(control.value)) {
|
|
950
|
+
if (!MonkeyEcxUtils.isValidZipCode(control.value, country)) {
|
|
950
951
|
return {
|
|
951
|
-
invalidZipCode: true
|
|
952
|
+
invalidZipCode: true
|
|
952
953
|
};
|
|
953
954
|
}
|
|
954
955
|
}
|
|
@@ -960,14 +961,14 @@ function documentValidator(control, country) {
|
|
|
960
961
|
if (country === 'BR') {
|
|
961
962
|
if (!MonkeyEcxUtils.isCPFCNPJValid(control.value)) {
|
|
962
963
|
return {
|
|
963
|
-
invalidCpfCnpj: true
|
|
964
|
+
invalidCpfCnpj: true
|
|
964
965
|
};
|
|
965
966
|
}
|
|
966
967
|
}
|
|
967
968
|
else if (country === 'CL') {
|
|
968
969
|
if (!MonkeyEcxUtils.isValidRUT(control.value)) {
|
|
969
970
|
return {
|
|
970
|
-
invalidCpfCnpj: true
|
|
971
|
+
invalidCpfCnpj: true
|
|
971
972
|
};
|
|
972
973
|
}
|
|
973
974
|
}
|
|
@@ -981,7 +982,7 @@ function dateValidator(control) {
|
|
|
981
982
|
.default(moment$2.default(control.value).format(dateFormat), ['DD/MM/YYYY', 'MM-DD-YYYY', 'YYYY-MM-DD'], true)
|
|
982
983
|
.isValid()) {
|
|
983
984
|
return {
|
|
984
|
-
invalidDate: true
|
|
985
|
+
invalidDate: true
|
|
985
986
|
};
|
|
986
987
|
}
|
|
987
988
|
return null;
|
|
@@ -991,7 +992,7 @@ function valueGreaterThanZero(control) {
|
|
|
991
992
|
return null;
|
|
992
993
|
if (control && `${control?.value}` === '0') {
|
|
993
994
|
return {
|
|
994
|
-
invalidValueGreaterThanZero: true
|
|
995
|
+
invalidValueGreaterThanZero: true
|
|
995
996
|
};
|
|
996
997
|
}
|
|
997
998
|
return null;
|
|
@@ -1027,6 +1028,11 @@ class Validators {
|
|
|
1027
1028
|
static zipCode(control) {
|
|
1028
1029
|
return zipCodeValidator(control);
|
|
1029
1030
|
}
|
|
1031
|
+
static zipCodeByCountry(country) {
|
|
1032
|
+
return (control) => {
|
|
1033
|
+
return zipCodeValidator(control, country);
|
|
1034
|
+
};
|
|
1035
|
+
}
|
|
1030
1036
|
static documentBR(control) {
|
|
1031
1037
|
return documentValidator(control, 'BR');
|
|
1032
1038
|
}
|