@nest-boot/validator 3.1.2 → 4.0.0-beta.2
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/dist/decorators/common/array-length.decorator.js +27 -24
- package/dist/decorators/common/array-length.decorator.js.map +1 -1
- package/dist/decorators/number/max.decorator.js +2 -1
- package/dist/decorators/number/max.decorator.js.map +1 -1
- package/dist/decorators/number/min.decorator.js +2 -1
- package/dist/decorators/number/min.decorator.js.map +1 -1
- package/dist/decorators/number/validate-compare-number.decorator.js +44 -39
- package/dist/decorators/number/validate-compare-number.decorator.js.map +1 -1
- package/dist/decorators/string/is-email.decorator.js +1 -1
- package/dist/decorators/string/is-email.decorator.js.map +1 -1
- package/dist/decorators/string/is-number-string.decorator.js +2 -1
- package/dist/decorators/string/is-number-string.decorator.js.map +1 -1
- package/dist/decorators/string/is-timezone.decorator.js +1 -1
- package/dist/decorators/string/is-timezone.decorator.js.map +1 -1
- package/dist/decorators/string/is-url.decorator.js +1 -1
- package/dist/decorators/string/is-url.decorator.js.map +1 -1
- package/dist/decorators/string/length.decorator.js +10 -7
- package/dist/decorators/string/length.decorator.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/utils/build-i18n-message.d.ts +1 -1
- package/dist/utils/build-i18n-message.js.map +1 -1
- package/package.json +27 -12
- package/README.md +0 -11
- package/dist/tsconfig.build.tsbuildinfo +0 -1
|
@@ -6,20 +6,20 @@ const class_validator_1 = require("class-validator");
|
|
|
6
6
|
function arrayLengthMessage(value, property, min, max) {
|
|
7
7
|
const t = (0, i18next_1.getTranslation)();
|
|
8
8
|
if (Array.isArray(value)) {
|
|
9
|
-
if (min && max) {
|
|
9
|
+
if (typeof min !== "undefined" && typeof max !== "undefined") {
|
|
10
10
|
return t("validation:arrayLength.between", {
|
|
11
11
|
property: t(`property:${property}`),
|
|
12
12
|
min,
|
|
13
13
|
max,
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
|
-
if (min && value.length < min) {
|
|
16
|
+
if (typeof min !== "undefined" && value.length < min) {
|
|
17
17
|
return t("validation:arrayLength.gte", {
|
|
18
18
|
property: t(`property:${property}`),
|
|
19
19
|
compareProperty: `${min}`,
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
|
-
if (max && value.length > max) {
|
|
22
|
+
if (typeof max !== "undefined" && value.length > max) {
|
|
23
23
|
return t("validation:arrayLength.lte", {
|
|
24
24
|
property: t(`property:${property}`),
|
|
25
25
|
compareProperty: `${max}`,
|
|
@@ -32,29 +32,32 @@ function arrayLengthMessage(value, property, min, max) {
|
|
|
32
32
|
}
|
|
33
33
|
function ArrayLength(validationOptions) {
|
|
34
34
|
return (target, propertyName) => {
|
|
35
|
-
(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
35
|
+
if (typeof propertyName === "string") {
|
|
36
|
+
(0, class_validator_1.registerDecorator)({
|
|
37
|
+
name: "arrayLength",
|
|
38
|
+
target: target.constructor,
|
|
39
|
+
propertyName,
|
|
40
|
+
options: validationOptions,
|
|
41
|
+
validator: {
|
|
42
|
+
validate(value) {
|
|
43
|
+
if (Array.isArray(value)) {
|
|
44
|
+
const { min, max } = validationOptions;
|
|
45
|
+
if ((typeof min !== "undefined" && value.length < min) ||
|
|
46
|
+
(typeof max !== "undefined" && value.length > max)) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
return true;
|
|
46
50
|
}
|
|
47
|
-
return
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return arrayLengthMessage(value, property, min, max);
|
|
51
|
+
return false;
|
|
52
|
+
},
|
|
53
|
+
defaultMessage(args) {
|
|
54
|
+
const { value, property } = args;
|
|
55
|
+
const { min, max } = validationOptions;
|
|
56
|
+
return arrayLengthMessage(value, property, min, max);
|
|
57
|
+
},
|
|
55
58
|
},
|
|
56
|
-
}
|
|
57
|
-
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
58
61
|
};
|
|
59
62
|
}
|
|
60
63
|
exports.ArrayLength = ArrayLength;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-length.decorator.js","sourceRoot":"","sources":["../../../src/decorators/common/array-length.decorator.ts"],"names":[],"mappings":";;;AAAA,gDAAoD;AACpD,
|
|
1
|
+
{"version":3,"file":"array-length.decorator.js","sourceRoot":"","sources":["../../../src/decorators/common/array-length.decorator.ts"],"names":[],"mappings":";;;AAAA,gDAAoD;AACpD,qDAIyB;AAOzB,SAAS,kBAAkB,CACzB,KAAc,EACd,QAAgB,EAChB,GAAY,EACZ,GAAY;IAEZ,MAAM,CAAC,GAAG,IAAA,wBAAc,GAAE,CAAC;IAC3B,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACxB,IAAI,OAAO,GAAG,KAAK,WAAW,IAAI,OAAO,GAAG,KAAK,WAAW,EAAE;YAC5D,OAAO,CAAC,CAAC,gCAAgC,EAAE;gBACzC,QAAQ,EAAE,CAAC,CAAC,YAAY,QAAQ,EAAE,CAAC;gBACnC,GAAG;gBACH,GAAG;aACJ,CAAC,CAAC;SACJ;QAGD,IAAI,OAAO,GAAG,KAAK,WAAW,IAAI,KAAK,CAAC,MAAM,GAAG,GAAG,EAAE;YACpD,OAAO,CAAC,CAAC,4BAA4B,EAAE;gBACrC,QAAQ,EAAE,CAAC,CAAC,YAAY,QAAQ,EAAE,CAAC;gBACnC,eAAe,EAAE,GAAG,GAAG,EAAE;aAC1B,CAAC,CAAC;SACJ;QAGD,IAAI,OAAO,GAAG,KAAK,WAAW,IAAI,KAAK,CAAC,MAAM,GAAG,GAAG,EAAE;YACpD,OAAO,CAAC,CAAC,4BAA4B,EAAE;gBACrC,QAAQ,EAAE,CAAC,CAAC,YAAY,QAAQ,EAAE,CAAC;gBAC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Value, validationOptions) {
|
|
|
8
8
|
name: "max",
|
|
9
9
|
constraints: [maxValue],
|
|
10
10
|
validator: {
|
|
11
|
-
validate: (value, args) =>
|
|
11
|
+
validate: (value, args) => typeof args !== "undefined" &&
|
|
12
|
+
Number(value) <= Number(args.constraints[0]),
|
|
12
13
|
defaultMessage: (0, utils_1.buildI18nMessage)(() => "max"),
|
|
13
14
|
},
|
|
14
15
|
}, validationOptions);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"max.decorator.js","sourceRoot":"","sources":["../../../src/decorators/number/max.decorator.ts"],"names":[],"mappings":";;;AAAA,qDAAgE;AAEhE,uCAA+C;AAE/C,SAAgB,GAAG,CACjB,QAAgB,EAChB,iBAAqC;IAErC,OAAO,IAAA,4BAAU,EACf;QACE,IAAI,EAAE,KAAK;QACX,WAAW,EAAE,CAAC,QAAQ,CAAC;QACvB,SAAS,EAAE;YACT,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CACjC,MAAM,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YAC9C,cAAc,EAAE,IAAA,wBAAgB,EAAC,GAAG,EAAE,CAAC,KAAK,CAAC;SAC9C;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC;
|
|
1
|
+
{"version":3,"file":"max.decorator.js","sourceRoot":"","sources":["../../../src/decorators/number/max.decorator.ts"],"names":[],"mappings":";;;AAAA,qDAAgE;AAEhE,uCAA+C;AAE/C,SAAgB,GAAG,CACjB,QAAgB,EAChB,iBAAqC;IAErC,OAAO,IAAA,4BAAU,EACf;QACE,IAAI,EAAE,KAAK;QACX,WAAW,EAAE,CAAC,QAAQ,CAAC;QACvB,SAAS,EAAE;YACT,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CACjC,OAAO,IAAI,KAAK,WAAW;gBAC3B,MAAM,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YAC9C,cAAc,EAAE,IAAA,wBAAgB,EAAC,GAAG,EAAE,CAAC,KAAK,CAAC;SAC9C;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC;AAjBD,kBAiBC"}
|
|
@@ -8,7 +8,8 @@ function Min(minValue, validationOptions) {
|
|
|
8
8
|
name: "min",
|
|
9
9
|
constraints: [minValue],
|
|
10
10
|
validator: {
|
|
11
|
-
validate: (value, args) =>
|
|
11
|
+
validate: (value, args) => typeof args !== "undefined" &&
|
|
12
|
+
Number(value) >= Number(args.constraints[0]),
|
|
12
13
|
defaultMessage: (0, utils_1.buildI18nMessage)(() => "min"),
|
|
13
14
|
},
|
|
14
15
|
}, validationOptions);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"min.decorator.js","sourceRoot":"","sources":["../../../src/decorators/number/min.decorator.ts"],"names":[],"mappings":";;;AAAA,qDAAgE;AAEhE,uCAA+C;AAE/C,SAAgB,GAAG,CACjB,QAAgB,EAChB,iBAAqC;IAErC,OAAO,IAAA,4BAAU,EACf;QACE,IAAI,EAAE,KAAK;QACX,WAAW,EAAE,CAAC,QAAQ,CAAC;QACvB,SAAS,EAAE;YACT,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CACjC,MAAM,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YAC9C,cAAc,EAAE,IAAA,wBAAgB,EAAC,GAAG,EAAE,CAAC,KAAK,CAAC;SAC9C;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC;
|
|
1
|
+
{"version":3,"file":"min.decorator.js","sourceRoot":"","sources":["../../../src/decorators/number/min.decorator.ts"],"names":[],"mappings":";;;AAAA,qDAAgE;AAEhE,uCAA+C;AAE/C,SAAgB,GAAG,CACjB,QAAgB,EAChB,iBAAqC;IAErC,OAAO,IAAA,4BAAU,EACf;QACE,IAAI,EAAE,KAAK;QACX,WAAW,EAAE,CAAC,QAAQ,CAAC;QACvB,SAAS,EAAE;YACT,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CACjC,OAAO,IAAI,KAAK,WAAW;gBAC3B,MAAM,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YAC9C,cAAc,EAAE,IAAA,wBAAgB,EAAC,GAAG,EAAE,CAAC,KAAK,CAAC;SAC9C;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC;AAjBD,kBAiBC"}
|
|
@@ -12,47 +12,52 @@ var Comparator;
|
|
|
12
12
|
Comparator["LTE"] = "LTE";
|
|
13
13
|
})(Comparator = exports.Comparator || (exports.Comparator = {}));
|
|
14
14
|
function ValidateCompareNumber(comparator, compareProperty, validationOptions) {
|
|
15
|
-
return (target,
|
|
16
|
-
(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (compareValue === undefined || compareValue === null) {
|
|
27
|
-
return true;
|
|
28
|
-
}
|
|
29
|
-
switch (innerComparator) {
|
|
30
|
-
case Comparator.EQ:
|
|
31
|
-
return Number(value) === Number(compareValue);
|
|
32
|
-
case Comparator.GT:
|
|
33
|
-
return Number(value) > Number(compareValue);
|
|
34
|
-
case Comparator.GTE:
|
|
35
|
-
return Number(value) >= Number(compareValue);
|
|
36
|
-
case Comparator.LT:
|
|
37
|
-
return Number(value) < Number(compareValue);
|
|
38
|
-
case Comparator.LTE:
|
|
39
|
-
return Number(value) <= Number(compareValue);
|
|
40
|
-
default:
|
|
15
|
+
return (target, propertyName) => {
|
|
16
|
+
if (typeof propertyName === "string") {
|
|
17
|
+
(0, class_validator_1.registerDecorator)({
|
|
18
|
+
name: "isGreaterThanOrEqual",
|
|
19
|
+
target: target.constructor,
|
|
20
|
+
propertyName,
|
|
21
|
+
constraints: [comparator, compareProperty],
|
|
22
|
+
options: validationOptions,
|
|
23
|
+
validator: {
|
|
24
|
+
validate(value, args) {
|
|
25
|
+
if (typeof args === "undefined") {
|
|
41
26
|
return false;
|
|
42
|
-
|
|
27
|
+
}
|
|
28
|
+
const [innerComparator, innerCompareProperty] = args.constraints;
|
|
29
|
+
const compareValue = args.object[innerCompareProperty];
|
|
30
|
+
if (compareValue === undefined || compareValue === null) {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
switch (innerComparator) {
|
|
34
|
+
case Comparator.EQ:
|
|
35
|
+
return Number(value) === Number(compareValue);
|
|
36
|
+
case Comparator.GT:
|
|
37
|
+
return Number(value) > Number(compareValue);
|
|
38
|
+
case Comparator.GTE:
|
|
39
|
+
return Number(value) >= Number(compareValue);
|
|
40
|
+
case Comparator.LT:
|
|
41
|
+
return Number(value) < Number(compareValue);
|
|
42
|
+
case Comparator.LTE:
|
|
43
|
+
return Number(value) <= Number(compareValue);
|
|
44
|
+
default:
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
defaultMessage(args) {
|
|
49
|
+
const t = (0, i18next_1.getTranslation)();
|
|
50
|
+
const { property, constraints } = args;
|
|
51
|
+
const [innerComparator, innerCompareProperty] = constraints;
|
|
52
|
+
return t(`validation:is-${innerComparator.toLowerCase()}`, {
|
|
53
|
+
...args,
|
|
54
|
+
property: t(`property:${property}`),
|
|
55
|
+
compareProperty: t(`property:${innerCompareProperty}`),
|
|
56
|
+
});
|
|
57
|
+
},
|
|
43
58
|
},
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const { property, constraints } = args;
|
|
47
|
-
const [innerComparator, innerCompareProperty] = constraints;
|
|
48
|
-
return t(`validation:is-${innerComparator.toLowerCase()}`, {
|
|
49
|
-
...args,
|
|
50
|
-
property: t(`property:${property}`),
|
|
51
|
-
compareProperty: t(`property:${innerCompareProperty}`),
|
|
52
|
-
});
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
});
|
|
59
|
+
});
|
|
60
|
+
}
|
|
56
61
|
};
|
|
57
62
|
}
|
|
58
63
|
exports.ValidateCompareNumber = ValidateCompareNumber;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-compare-number.decorator.js","sourceRoot":"","sources":["../../../src/decorators/number/validate-compare-number.decorator.ts"],"names":[],"mappings":";;;AAAA,gDAAoD;AACpD,qDAIyB;AAEzB,IAAY,UAMX;AAND,WAAY,UAAU;IACpB,uBAAS,CAAA;IACT,uBAAS,CAAA;IACT,yBAAW,CAAA;IACX,uBAAS,CAAA;IACT,yBAAW,CAAA;AACb,CAAC,EANW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAMrB;AAED,SAAgB,qBAAqB,CACnC,UAAsB,EACtB,eAAuB,EACvB,iBAAqC;IAErC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"validate-compare-number.decorator.js","sourceRoot":"","sources":["../../../src/decorators/number/validate-compare-number.decorator.ts"],"names":[],"mappings":";;;AAAA,gDAAoD;AACpD,qDAIyB;AAEzB,IAAY,UAMX;AAND,WAAY,UAAU;IACpB,uBAAS,CAAA;IACT,uBAAS,CAAA;IACT,yBAAW,CAAA;IACX,uBAAS,CAAA;IACT,yBAAW,CAAA;AACb,CAAC,EANW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAMrB;AAED,SAAgB,qBAAqB,CACnC,UAAsB,EACtB,eAAuB,EACvB,iBAAqC;IAErC,OAAO,CAAC,MAAc,EAAE,YAA6B,EAAE,EAAE;QACvD,IAAI,OAAO,YAAY,KAAK,QAAQ,EAAE;YACpC,IAAA,mCAAiB,EAAC;gBAChB,IAAI,EAAE,sBAAsB;gBAC5B,MAAM,EAAE,MAAM,CAAC,WAAW;gBAC1B,YAAY;gBACZ,WAAW,EAAE,CAAC,UAAU,EAAE,eAAe,CAAC;gBAC1C,OAAO,EAAE,iBAA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AC,WAAW,EAAE,EAAE,EAAE;4BACzD,GAAG,IAAI;4BACP,QAAQ,EAAE,CAAC,CAAC,YAAY,QAAQ,EAAE,CAAC;4BACnC,eAAe,EAAE,CAAC,CAAC,YAAY,oBAAoB,EAAE,CAAC;yBACvD,CAAC,CAAC;oBACL,CAAC;iBACF;aACF,CAAC,CAAC;SACJ;IACH,CAAC,CAAC;AACJ,CAAC;AA9DD,sDA8DC"}
|
|
@@ -17,7 +17,7 @@ function IsEmail(options, validationOptions) {
|
|
|
17
17
|
name: exports.IS_EMAIL,
|
|
18
18
|
constraints: [options],
|
|
19
19
|
validator: {
|
|
20
|
-
validate: (value, args) => isEmail(value, args.constraints[0]),
|
|
20
|
+
validate: (value, args) => typeof args !== "undefined" && isEmail(value, args.constraints[0]),
|
|
21
21
|
defaultMessage: (0, utils_1.buildI18nMessage)(() => "is-email"),
|
|
22
22
|
},
|
|
23
23
|
}, validationOptions);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-email.decorator.js","sourceRoot":"","sources":["../../../src/decorators/string/is-email.decorator.ts"],"names":[],"mappings":";;;;;;AAAA,qDAAgE;AAEhE,oEAAqD;AAErD,uCAA+C;AAElC,QAAA,QAAQ,GAAG,SAAS,CAAC;AAMlC,SAAgB,OAAO,CACrB,KAAc,EACd,OAAoC;IAEpC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,IAAA,iBAAgB,EAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AACvE,CAAC;AALD,0BAKC;AAMD,SAAgB,OAAO,CACrB,OAAoC,EACpC,iBAAqC;IAErC,OAAO,IAAA,4BAAU,EACf;QACE,IAAI,EAAE,gBAAQ;QACd,WAAW,EAAE,CAAC,OAAO,CAAC;QACtB,SAAS,EAAE;YACT,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"is-email.decorator.js","sourceRoot":"","sources":["../../../src/decorators/string/is-email.decorator.ts"],"names":[],"mappings":";;;;;;AAAA,qDAAgE;AAEhE,oEAAqD;AAErD,uCAA+C;AAElC,QAAA,QAAQ,GAAG,SAAS,CAAC;AAMlC,SAAgB,OAAO,CACrB,KAAc,EACd,OAAoC;IAEpC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,IAAA,iBAAgB,EAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AACvE,CAAC;AALD,0BAKC;AAMD,SAAgB,OAAO,CACrB,OAAoC,EACpC,iBAAqC;IAErC,OAAO,IAAA,4BAAU,EACf;QACE,IAAI,EAAE,gBAAQ;QACd,WAAW,EAAE,CAAC,OAAO,CAAC;QACtB,SAAS,EAAE;YACT,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CACjC,OAAO,IAAI,KAAK,WAAW,IAAI,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YACpE,cAAc,EAAE,IAAA,wBAAgB,EAAC,GAAG,EAAE,CAAC,UAAU,CAAC;SACnD;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC;AAhBD,0BAgBC"}
|
|
@@ -17,7 +17,8 @@ function IsNumberString(options, validationOptions) {
|
|
|
17
17
|
name: exports.IS_NUMBER_STRING,
|
|
18
18
|
constraints: [options],
|
|
19
19
|
validator: {
|
|
20
|
-
validate: (value, args) =>
|
|
20
|
+
validate: (value, args) => typeof args !== "undefined" &&
|
|
21
|
+
isNumberString(value, args.constraints[0]),
|
|
21
22
|
defaultMessage: (0, utils_1.buildI18nMessage)(() => "is-number-string"),
|
|
22
23
|
},
|
|
23
24
|
}, validationOptions);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-number-string.decorator.js","sourceRoot":"","sources":["../../../src/decorators/string/is-number-string.decorator.ts"],"names":[],"mappings":";;;;;;AAAA,qDAAgE;AAEhE,wEAAyD;AAEzD,uCAA+C;AAElC,QAAA,gBAAgB,GAAG,gBAAgB,CAAC;AAMjD,SAAgB,cAAc,CAC5B,KAAc,EACd,OAAsC;IAEtC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,IAAA,mBAAkB,EAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AACzE,CAAC;AALD,wCAKC;AAMD,SAAgB,cAAc,CAC5B,OAAsC,EACtC,iBAAqC;IAErC,OAAO,IAAA,4BAAU,EACf;QACE,IAAI,EAAE,wBAAgB;QACtB,WAAW,EAAE,CAAC,OAAO,CAAC;QACtB,SAAS,EAAE;YACT,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CACjC,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YAC5C,cAAc,EAAE,IAAA,wBAAgB,EAAC,GAAG,EAAE,CAAC,kBAAkB,CAAC;SAC3D;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC;
|
|
1
|
+
{"version":3,"file":"is-number-string.decorator.js","sourceRoot":"","sources":["../../../src/decorators/string/is-number-string.decorator.ts"],"names":[],"mappings":";;;;;;AAAA,qDAAgE;AAEhE,wEAAyD;AAEzD,uCAA+C;AAElC,QAAA,gBAAgB,GAAG,gBAAgB,CAAC;AAMjD,SAAgB,cAAc,CAC5B,KAAc,EACd,OAAsC;IAEtC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,IAAA,mBAAkB,EAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AACzE,CAAC;AALD,wCAKC;AAMD,SAAgB,cAAc,CAC5B,OAAsC,EACtC,iBAAqC;IAErC,OAAO,IAAA,4BAAU,EACf;QACE,IAAI,EAAE,wBAAgB;QACtB,WAAW,EAAE,CAAC,OAAO,CAAC;QACtB,SAAS,EAAE;YACT,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CACjC,OAAO,IAAI,KAAK,WAAW;gBAC3B,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YAC5C,cAAc,EAAE,IAAA,wBAAgB,EAAC,GAAG,EAAE,CAAC,kBAAkB,CAAC;SAC3D;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC;AAjBD,wCAiBC"}
|
|
@@ -11,7 +11,7 @@ function IsTimezone(validationOptions) {
|
|
|
11
11
|
return (0, class_validator_1.ValidateBy)({
|
|
12
12
|
name: "isTimezone",
|
|
13
13
|
validator: {
|
|
14
|
-
validate: (value) => typeof value === "string" &&
|
|
14
|
+
validate: (value) => typeof value === "string" && !(moment_timezone_1.default.tz.zone(value) == null),
|
|
15
15
|
defaultMessage: (0, utils_1.buildI18nMessage)(() => "is-timezone"),
|
|
16
16
|
},
|
|
17
17
|
}, validationOptions);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-timezone.decorator.js","sourceRoot":"","sources":["../../../src/decorators/string/is-timezone.decorator.ts"],"names":[],"mappings":";;;;;;AAAA,qDAAgE;AAChE,sEAAqC;AAErC,uCAA+C;AAE/C,SAAgB,UAAU,CACxB,iBAAqC;IAErC,OAAO,IAAA,4BAAU,EACf;QACE,IAAI,EAAE,YAAY;QAClB,SAAS,EAAE;YACT,QAAQ,EAAE,CAAC,KAAK,EAAW,EAAE,CAC3B,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,CAAC,yBAAM,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"is-timezone.decorator.js","sourceRoot":"","sources":["../../../src/decorators/string/is-timezone.decorator.ts"],"names":[],"mappings":";;;;;;AAAA,qDAAgE;AAChE,sEAAqC;AAErC,uCAA+C;AAE/C,SAAgB,UAAU,CACxB,iBAAqC;IAErC,OAAO,IAAA,4BAAU,EACf;QACE,IAAI,EAAE,YAAY;QAClB,SAAS,EAAE;YACT,QAAQ,EAAE,CAAC,KAAK,EAAW,EAAE,CAC3B,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,CAAC,yBAAM,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC;YAC/D,cAAc,EAAE,IAAA,wBAAgB,EAAC,GAAG,EAAE,CAAC,aAAa,CAAC;SACtD;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC;AAdD,gCAcC"}
|
|
@@ -17,7 +17,7 @@ function IsUrl(options, validationOptions) {
|
|
|
17
17
|
name: exports.IS_URL,
|
|
18
18
|
constraints: [options],
|
|
19
19
|
validator: {
|
|
20
|
-
validate: (value, args) => isURL(value, args.constraints[0]),
|
|
20
|
+
validate: (value, args) => typeof args !== "undefined" && isURL(value, args.constraints[0]),
|
|
21
21
|
defaultMessage: (0, utils_1.buildI18nMessage)(() => "is-url"),
|
|
22
22
|
},
|
|
23
23
|
}, validationOptions);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-url.decorator.js","sourceRoot":"","sources":["../../../src/decorators/string/is-url.decorator.ts"],"names":[],"mappings":";;;;;;AAAA,qDAAgE;AAEhE,gEAAiD;AAEjD,uCAA+C;AAElC,QAAA,MAAM,GAAG,OAAO,CAAC;AAM9B,SAAgB,KAAK,CACnB,KAAa,EACb,OAAkC;IAElC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,IAAA,eAAc,EAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AACrE,CAAC;AALD,sBAKC;AAMD,SAAgB,KAAK,CACnB,OAAkC,EAClC,iBAAqC;IAErC,OAAO,IAAA,4BAAU,EACf;QACE,IAAI,EAAE,cAAM;QACZ,WAAW,EAAE,CAAC,OAAO,CAAC;QACtB,SAAS,EAAE;YACT,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"is-url.decorator.js","sourceRoot":"","sources":["../../../src/decorators/string/is-url.decorator.ts"],"names":[],"mappings":";;;;;;AAAA,qDAAgE;AAEhE,gEAAiD;AAEjD,uCAA+C;AAElC,QAAA,MAAM,GAAG,OAAO,CAAC;AAM9B,SAAgB,KAAK,CACnB,KAAa,EACb,OAAkC;IAElC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,IAAA,eAAc,EAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AACrE,CAAC;AALD,sBAKC;AAMD,SAAgB,KAAK,CACnB,OAAkC,EAClC,iBAAqC;IAErC,OAAO,IAAA,4BAAU,EACf;QACE,IAAI,EAAE,cAAM;QACZ,WAAW,EAAE,CAAC,OAAO,CAAC;QACtB,SAAS,EAAE;YACT,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CACjC,OAAO,IAAI,KAAK,WAAW,IAAI,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YAClE,cAAc,EAAE,IAAA,wBAAgB,EAAC,GAAG,EAAE,CAAC,QAAQ,CAAC;SACjD;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC;AAhBD,sBAgBC"}
|
|
@@ -17,14 +17,17 @@ function Length(min, max, validationOptions) {
|
|
|
17
17
|
name: exports.IS_LENGTH,
|
|
18
18
|
constraints: [min, max],
|
|
19
19
|
validator: {
|
|
20
|
-
validate: (value, args) =>
|
|
20
|
+
validate: (value, args) => typeof args !== "undefined" &&
|
|
21
|
+
length(value, args.constraints[0], args.constraints[1]),
|
|
21
22
|
defaultMessage: (0, build_i18n_message_1.buildI18nMessage)((args) => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
if (typeof args !== "undefined") {
|
|
24
|
+
const isMinLength = args.constraints[0] !== null && args.constraints[0] !== undefined;
|
|
25
|
+
const isMaxLength = args.constraints[1] !== null && args.constraints[1] !== undefined;
|
|
26
|
+
if (isMinLength &&
|
|
27
|
+
!isMaxLength &&
|
|
28
|
+
args.value.length < args.constraints[0]) {
|
|
29
|
+
return "length.gte";
|
|
30
|
+
}
|
|
28
31
|
}
|
|
29
32
|
return "length.between";
|
|
30
33
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"length.decorator.js","sourceRoot":"","sources":["../../../src/decorators/string/length.decorator.ts"],"names":[],"mappings":";;;;;;AAAA,qDAAgE;AAChE,sEAAuD;AAEvD,uEAAkE;AAErD,QAAA,SAAS,GAAG,UAAU,CAAC;AAMpC,SAAgB,MAAM,CAAC,KAAc,EAAE,GAAW,EAAE,GAAY;IAC9D,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,IAAA,kBAAiB,EAAC,KAAK,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;AAC7E,CAAC;AAFD,wBAEC;AAMD,SAAgB,MAAM,CACpB,GAAW,EACX,GAAY,EACZ,iBAAqC;IAErC,OAAO,IAAA,4BAAU,EACf;QACE,IAAI,EAAE,iBAAS;QACf,WAAW,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC;QACvB,SAAS,EAAE;YACT,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CACjC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YACzD,cAAc,EAAE,IAAA,qCAAgB,EAAC,CAAC,IAAI,EAAE,EAAE;gBACxC,MAAM,WAAW,GACf,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"length.decorator.js","sourceRoot":"","sources":["../../../src/decorators/string/length.decorator.ts"],"names":[],"mappings":";;;;;;AAAA,qDAAgE;AAChE,sEAAuD;AAEvD,uEAAkE;AAErD,QAAA,SAAS,GAAG,UAAU,CAAC;AAMpC,SAAgB,MAAM,CAAC,KAAc,EAAE,GAAW,EAAE,GAAY;IAC9D,OAAO,OA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