@nest-boot/validator 7.2.1 → 8.0.0-beta.0
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 +12 -15
- package/dist/decorators/common/array-length.decorator.js.map +1 -1
- package/dist/decorators/index.d.ts +14 -14
- package/dist/decorators/index.js +14 -30
- package/dist/decorators/index.js.map +1 -1
- package/dist/decorators/number/is-greater-than-or-equal.decorator.js +3 -6
- package/dist/decorators/number/is-greater-than-or-equal.decorator.js.map +1 -1
- package/dist/decorators/number/is-greater-than.decorator.js +3 -6
- package/dist/decorators/number/is-greater-than.decorator.js.map +1 -1
- package/dist/decorators/number/is-less-than-or-equal.decorator.js +3 -6
- package/dist/decorators/number/is-less-than-or-equal.decorator.js.map +1 -1
- package/dist/decorators/number/is-less-than.decorator.js +3 -6
- package/dist/decorators/number/is-less-than.decorator.js.map +1 -1
- package/dist/decorators/number/max.decorator.js +5 -8
- package/dist/decorators/number/max.decorator.js.map +1 -1
- package/dist/decorators/number/min.decorator.js +5 -8
- package/dist/decorators/number/min.decorator.js.map +1 -1
- package/dist/decorators/number/validate-compare-number.decorator.js +9 -13
- package/dist/decorators/number/validate-compare-number.decorator.js.map +1 -1
- package/dist/decorators/string/is-domain.decorator.js +5 -8
- package/dist/decorators/string/is-domain.decorator.js.map +1 -1
- package/dist/decorators/string/is-email.decorator.d.ts +1 -1
- package/dist/decorators/string/is-email.decorator.js +12 -18
- package/dist/decorators/string/is-email.decorator.js.map +1 -1
- package/dist/decorators/string/is-number-string.decorator.d.ts +1 -1
- package/dist/decorators/string/is-number-string.decorator.js +12 -18
- package/dist/decorators/string/is-number-string.decorator.js.map +1 -1
- package/dist/decorators/string/is-timezone.decorator.js +7 -13
- package/dist/decorators/string/is-timezone.decorator.js.map +1 -1
- package/dist/decorators/string/is-url.decorator.d.ts +1 -1
- package/dist/decorators/string/is-url.decorator.js +12 -18
- package/dist/decorators/string/is-url.decorator.js.map +1 -1
- package/dist/decorators/string/length.decorator.js +12 -18
- package/dist/decorators/string/length.decorator.js.map +1 -1
- package/dist/decorators/type-check/is-date.decorator.js +8 -13
- package/dist/decorators/type-check/is-date.decorator.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -22
- package/dist/index.js.map +1 -1
- package/dist/utils/build-i18n-message.js +4 -7
- package/dist/utils/build-i18n-message.js.map +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +1 -17
- package/dist/utils/index.js.map +1 -1
- package/package.json +14 -19
- package/dist/tsconfig.build.tsbuildinfo +0 -1
|
@@ -1,35 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.ArrayLength = ArrayLength;
|
|
4
|
-
const i18n_1 = require("@nest-boot/i18n");
|
|
5
|
-
const class_validator_1 = require("class-validator");
|
|
1
|
+
import { t } from "@nest-boot/i18n";
|
|
2
|
+
import { registerDecorator } from "class-validator";
|
|
6
3
|
function arrayLengthMessage(value, property, min, max) {
|
|
7
4
|
if (Array.isArray(value)) {
|
|
8
5
|
if (typeof min !== "undefined" && typeof max !== "undefined") {
|
|
9
|
-
return
|
|
10
|
-
property:
|
|
6
|
+
return t("validation:arrayLength.between", {
|
|
7
|
+
property: t(`property:${property}`),
|
|
11
8
|
min,
|
|
12
9
|
max,
|
|
13
10
|
});
|
|
14
11
|
}
|
|
15
12
|
// Length is less than required
|
|
16
13
|
if (typeof min !== "undefined" && value.length < min) {
|
|
17
|
-
return
|
|
18
|
-
property:
|
|
14
|
+
return t("validation:arrayLength.gte", {
|
|
15
|
+
property: t(`property:${property}`),
|
|
19
16
|
compareProperty: String(min),
|
|
20
17
|
});
|
|
21
18
|
}
|
|
22
19
|
// Length exceeds required
|
|
23
20
|
if (typeof max !== "undefined" && value.length > max) {
|
|
24
|
-
return
|
|
25
|
-
property:
|
|
21
|
+
return t("validation:arrayLength.lte", {
|
|
22
|
+
property: t(`property:${property}`),
|
|
26
23
|
compareProperty: String(max),
|
|
27
24
|
});
|
|
28
25
|
}
|
|
29
26
|
}
|
|
30
27
|
// Not an array
|
|
31
|
-
return
|
|
32
|
-
property:
|
|
28
|
+
return t("validation:is-array", {
|
|
29
|
+
property: t(`property:${property}`),
|
|
33
30
|
});
|
|
34
31
|
}
|
|
35
32
|
/**
|
|
@@ -37,10 +34,10 @@ function arrayLengthMessage(value, property, min, max) {
|
|
|
37
34
|
* @param validationOptions - Array length constraints and validation options
|
|
38
35
|
* @returns Property decorator
|
|
39
36
|
*/
|
|
40
|
-
function ArrayLength(validationOptions) {
|
|
37
|
+
export function ArrayLength(validationOptions) {
|
|
41
38
|
return (target, propertyName) => {
|
|
42
39
|
if (typeof propertyName === "string") {
|
|
43
|
-
|
|
40
|
+
registerDecorator({
|
|
44
41
|
name: "arrayLength",
|
|
45
42
|
target: target.constructor,
|
|
46
43
|
propertyName,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-length.decorator.js","sourceRoot":"","sources":["../../../src/decorators/common/array-length.decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"array-length.decorator.js","sourceRoot":"","sources":["../../../src/decorators/common/array-length.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,iBAAiB,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAA0B,MAAM,iBAAiB,CAAC;AAU5E,SAAS,kBAAkB,CACzB,KAAc,EACd,QAAgB,EAChB,GAAY,EACZ,GAAY;IAEZ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,IAAI,OAAO,GAAG,KAAK,WAAW,IAAI,OAAO,GAAG,KAAK,WAAW,EAAE,CAAC;YAC7D,OAAO,CAAC,CAAC,gCAAgC,EAAE;gBACzC,QAAQ,EAAE,CAAC,CAAC,YAAY,QAAQ,EAAE,CAAC;gBACnC,GAAG;gBACH,GAAG;aACJ,CAAC,CAAC;QACL,CAAC;QAED,+BAA+B;QAC/B,IAAI,OAAO,GAAG,KAAK,WAAW,IAAI,KAAK,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC;YACrD,OAAO,CAAC,CAAC,4BAA4B,EAAE;gBACrC,QAAQ,EAAE,CAAC,CAAC,YAAY,QAAQ,EAAE,CAAC;gBACnC,eAAe,EAAE,MAAM,CAAC,GAAG,CAAC;aAC7B,CAAC,CAAC;QACL,CAAC;QAED,0BAA0B;QAC1B,IAAI,OAAO,GAAG,KAAK,WAAW,IAAI,KAAK,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC;YACrD,OAAO,CAAC,CAAC,4BAA4B,EAAE;gBACrC,QAAQ,EAAE,CAAC,CAAC,YAAY,QAAQ,EAAE,CAAC;gBACnC,eAAe,EAAE,MAAM,CAAC,GAAG,CAAC;aAC7B,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,eAAe;IACf,OAAO,CAAC,CAAC,qBAAqB,EAAE;QAC9B,QAAQ,EAAE,CAAC,CAAC,YAAY,QAAQ,EAAE,CAAC;KACpC,CAAC,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CACzB,iBAAqC;IAErC,OAAO,CAAC,MAAc,EAAE,YAA6B,EAAE,EAAE;QACvD,IAAI,OAAO,YAAY,KAAK,QAAQ,EAAE,CAAC;YACrC,iBAAiB,CAAC;gBAChB,IAAI,EAAE,aAAa;gBACnB,MAAM,EAAE,MAAM,CAAC,WAAW;gBAC1B,YAAY;gBACZ,OAAO,EAAE,iBAAiB;gBAC1B,SAAS,EAAE;oBACT,QAAQ,CAAC,KAAc;wBACrB,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;4BACzB,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,iBAAiB,CAAC;4BAEvC,IACE,CAAC,OAAO,GAAG,KAAK,WAAW,IAAI,KAAK,CAAC,MAAM,GAAG,GAAG,CAAC;gCAClD,CAAC,OAAO,GAAG,KAAK,WAAW,IAAI,KAAK,CAAC,MAAM,GAAG,GAAG,CAAC,EAClD,CAAC;gCACD,OAAO,KAAK,CAAC;4BACf,CAAC;4BAED,OAAO,IAAI,CAAC;wBACd,CAAC;wBAED,eAAe;wBACf,OAAO,KAAK,CAAC;oBACf,CAAC;oBACD,cAAc,CAAC,IAAI;wBACjB,oEAAoE;wBACpE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,IAAK,CAAC;wBAClC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,iBAAiB,CAAC;wBACvC,OAAO,kBAAkB,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;oBACvD,CAAC;iBACF;aACF,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export * from "./common/array-length.decorator";
|
|
2
|
-
export * from "./string/is-domain.decorator";
|
|
3
|
-
export * from "./string/is-email.decorator";
|
|
4
|
-
export * from "./string/is-number-string.decorator";
|
|
5
|
-
export * from "./string/is-timezone.decorator";
|
|
6
|
-
export * from "./string/is-url.decorator";
|
|
7
|
-
export * from "./string/length.decorator";
|
|
8
|
-
export * from "./number/is-greater-than.decorator";
|
|
9
|
-
export * from "./number/is-greater-than-or-equal.decorator";
|
|
10
|
-
export * from "./number/is-less-than.decorator";
|
|
11
|
-
export * from "./number/is-less-than-or-equal.decorator";
|
|
12
|
-
export * from "./number/max.decorator";
|
|
13
|
-
export * from "./number/min.decorator";
|
|
14
|
-
export * from "./type-check/is-date.decorator";
|
|
1
|
+
export * from "./common/array-length.decorator.js";
|
|
2
|
+
export * from "./string/is-domain.decorator.js";
|
|
3
|
+
export * from "./string/is-email.decorator.js";
|
|
4
|
+
export * from "./string/is-number-string.decorator.js";
|
|
5
|
+
export * from "./string/is-timezone.decorator.js";
|
|
6
|
+
export * from "./string/is-url.decorator.js";
|
|
7
|
+
export * from "./string/length.decorator.js";
|
|
8
|
+
export * from "./number/is-greater-than.decorator.js";
|
|
9
|
+
export * from "./number/is-greater-than-or-equal.decorator.js";
|
|
10
|
+
export * from "./number/is-less-than.decorator.js";
|
|
11
|
+
export * from "./number/is-less-than-or-equal.decorator.js";
|
|
12
|
+
export * from "./number/max.decorator.js";
|
|
13
|
+
export * from "./number/min.decorator.js";
|
|
14
|
+
export * from "./type-check/is-date.decorator.js";
|
package/dist/decorators/index.js
CHANGED
|
@@ -1,35 +1,19 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
1
|
// Common
|
|
18
|
-
|
|
2
|
+
export * from "./common/array-length.decorator.js";
|
|
19
3
|
// String
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
4
|
+
export * from "./string/is-domain.decorator.js";
|
|
5
|
+
export * from "./string/is-email.decorator.js";
|
|
6
|
+
export * from "./string/is-number-string.decorator.js";
|
|
7
|
+
export * from "./string/is-timezone.decorator.js";
|
|
8
|
+
export * from "./string/is-url.decorator.js";
|
|
9
|
+
export * from "./string/length.decorator.js";
|
|
26
10
|
// Number
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
11
|
+
export * from "./number/is-greater-than.decorator.js";
|
|
12
|
+
export * from "./number/is-greater-than-or-equal.decorator.js";
|
|
13
|
+
export * from "./number/is-less-than.decorator.js";
|
|
14
|
+
export * from "./number/is-less-than-or-equal.decorator.js";
|
|
15
|
+
export * from "./number/max.decorator.js";
|
|
16
|
+
export * from "./number/min.decorator.js";
|
|
33
17
|
// Type check
|
|
34
|
-
|
|
18
|
+
export * from "./type-check/is-date.decorator.js";
|
|
35
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"AAAA,SAAS;AACT,cAAc,oCAAoC,CAAC;AAEnD,SAAS;AACT,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,wCAAwC,CAAC;AACvD,cAAc,mCAAmC,CAAC;AAClD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAE7C,SAAS;AACT,cAAc,uCAAuC,CAAC;AACtD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,oCAAoC,CAAC;AACnD,cAAc,6CAA6C,CAAC;AAC5D,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAE1C,aAAa;AACb,cAAc,mCAAmC,CAAC"}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IsGreaterThanOrEqual = IsGreaterThanOrEqual;
|
|
4
|
-
const validate_compare_number_decorator_1 = require("./validate-compare-number.decorator");
|
|
1
|
+
import { Comparator, ValidateCompareNumber, } from "./validate-compare-number.decorator.js";
|
|
5
2
|
/**
|
|
6
3
|
* Validates that the property value is greater than or equal to the given field's value.
|
|
7
4
|
* @param field - The name of the property to compare against
|
|
8
5
|
* @param validationOptions - Optional class-validator validation options
|
|
9
6
|
* @returns Property decorator
|
|
10
7
|
*/
|
|
11
|
-
function IsGreaterThanOrEqual(field, validationOptions) {
|
|
12
|
-
return
|
|
8
|
+
export function IsGreaterThanOrEqual(field, validationOptions) {
|
|
9
|
+
return ValidateCompareNumber(Comparator.GTE, field, validationOptions);
|
|
13
10
|
}
|
|
14
11
|
//# sourceMappingURL=is-greater-than-or-equal.decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-greater-than-or-equal.decorator.js","sourceRoot":"","sources":["../../../src/decorators/number/is-greater-than-or-equal.decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"is-greater-than-or-equal.decorator.js","sourceRoot":"","sources":["../../../src/decorators/number/is-greater-than-or-equal.decorator.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,UAAU,EACV,qBAAqB,GACtB,MAAM,wCAAwC,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAClC,KAAa,EACb,iBAAqC;IAErC,OAAO,qBAAqB,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,EAAE,iBAAiB,CAAC,CAAC;AACzE,CAAC"}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IsGreaterThan = IsGreaterThan;
|
|
4
|
-
const validate_compare_number_decorator_1 = require("./validate-compare-number.decorator");
|
|
1
|
+
import { Comparator, ValidateCompareNumber, } from "./validate-compare-number.decorator.js";
|
|
5
2
|
/**
|
|
6
3
|
* Validates that the property value is greater than the given field's value.
|
|
7
4
|
* @param field - The name of the property to compare against
|
|
8
5
|
* @param validationOptions - Optional class-validator validation options
|
|
9
6
|
* @returns Property decorator
|
|
10
7
|
*/
|
|
11
|
-
function IsGreaterThan(field, validationOptions) {
|
|
12
|
-
return
|
|
8
|
+
export function IsGreaterThan(field, validationOptions) {
|
|
9
|
+
return ValidateCompareNumber(Comparator.GT, field, validationOptions);
|
|
13
10
|
}
|
|
14
11
|
//# sourceMappingURL=is-greater-than.decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-greater-than.decorator.js","sourceRoot":"","sources":["../../../src/decorators/number/is-greater-than.decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"is-greater-than.decorator.js","sourceRoot":"","sources":["../../../src/decorators/number/is-greater-than.decorator.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,UAAU,EACV,qBAAqB,GACtB,MAAM,wCAAwC,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAC3B,KAAa,EACb,iBAAqC;IAErC,OAAO,qBAAqB,CAAC,UAAU,CAAC,EAAE,EAAE,KAAK,EAAE,iBAAiB,CAAC,CAAC;AACxE,CAAC"}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IsLessThanOrEqual = IsLessThanOrEqual;
|
|
4
|
-
const validate_compare_number_decorator_1 = require("./validate-compare-number.decorator");
|
|
1
|
+
import { Comparator, ValidateCompareNumber, } from "./validate-compare-number.decorator.js";
|
|
5
2
|
/**
|
|
6
3
|
* Validates that the property value is less than or equal to the given field's value.
|
|
7
4
|
* @param field - The name of the property to compare against
|
|
8
5
|
* @param validationOptions - Optional class-validator validation options
|
|
9
6
|
* @returns Property decorator
|
|
10
7
|
*/
|
|
11
|
-
function IsLessThanOrEqual(field, validationOptions) {
|
|
12
|
-
return
|
|
8
|
+
export function IsLessThanOrEqual(field, validationOptions) {
|
|
9
|
+
return ValidateCompareNumber(Comparator.LTE, field, validationOptions);
|
|
13
10
|
}
|
|
14
11
|
//# sourceMappingURL=is-less-than-or-equal.decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-less-than-or-equal.decorator.js","sourceRoot":"","sources":["../../../src/decorators/number/is-less-than-or-equal.decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"is-less-than-or-equal.decorator.js","sourceRoot":"","sources":["../../../src/decorators/number/is-less-than-or-equal.decorator.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,UAAU,EACV,qBAAqB,GACtB,MAAM,wCAAwC,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAC/B,KAAa,EACb,iBAAqC;IAErC,OAAO,qBAAqB,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,EAAE,iBAAiB,CAAC,CAAC;AACzE,CAAC"}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IsLessThan = IsLessThan;
|
|
4
|
-
const validate_compare_number_decorator_1 = require("./validate-compare-number.decorator");
|
|
1
|
+
import { Comparator, ValidateCompareNumber, } from "./validate-compare-number.decorator.js";
|
|
5
2
|
/**
|
|
6
3
|
* Validates that the property value is less than the given field's value.
|
|
7
4
|
* @param field - The name of the property to compare against
|
|
8
5
|
* @param validationOptions - Optional class-validator validation options
|
|
9
6
|
* @returns Property decorator
|
|
10
7
|
*/
|
|
11
|
-
function IsLessThan(field, validationOptions) {
|
|
12
|
-
return
|
|
8
|
+
export function IsLessThan(field, validationOptions) {
|
|
9
|
+
return ValidateCompareNumber(Comparator.LT, field, validationOptions);
|
|
13
10
|
}
|
|
14
11
|
//# sourceMappingURL=is-less-than.decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-less-than.decorator.js","sourceRoot":"","sources":["../../../src/decorators/number/is-less-than.decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"is-less-than.decorator.js","sourceRoot":"","sources":["../../../src/decorators/number/is-less-than.decorator.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,UAAU,EACV,qBAAqB,GACtB,MAAM,wCAAwC,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CACxB,KAAa,EACb,iBAAqC;IAErC,OAAO,qBAAqB,CAAC,UAAU,CAAC,EAAE,EAAE,KAAK,EAAE,iBAAiB,CAAC,CAAC;AACxE,CAAC"}
|
|
@@ -1,22 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.Max = Max;
|
|
4
|
-
const class_validator_1 = require("class-validator");
|
|
5
|
-
const utils_1 = require("../../utils");
|
|
1
|
+
import { ValidateBy } from "class-validator";
|
|
2
|
+
import { buildI18nMessage } from "../../utils/index.js";
|
|
6
3
|
/**
|
|
7
4
|
* Validates that the property value is less than or equal to the specified maximum.
|
|
8
5
|
* @param maxValue - The maximum allowed value
|
|
9
6
|
* @param validationOptions - Optional class-validator validation options
|
|
10
7
|
* @returns Property decorator
|
|
11
8
|
*/
|
|
12
|
-
function Max(maxValue, validationOptions) {
|
|
13
|
-
return
|
|
9
|
+
export function Max(maxValue, validationOptions) {
|
|
10
|
+
return ValidateBy({
|
|
14
11
|
name: "max",
|
|
15
12
|
constraints: [maxValue],
|
|
16
13
|
validator: {
|
|
17
14
|
validate: (value, args) => typeof args !== "undefined" &&
|
|
18
15
|
Number(value) <= Number(args.constraints[0]),
|
|
19
|
-
defaultMessage:
|
|
16
|
+
defaultMessage: buildI18nMessage(() => "max"),
|
|
20
17
|
},
|
|
21
18
|
}, validationOptions);
|
|
22
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"max.decorator.js","sourceRoot":"","sources":["../../../src/decorators/number/max.decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"max.decorator.js","sourceRoot":"","sources":["../../../src/decorators/number/max.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA0B,MAAM,iBAAiB,CAAC;AAErE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD;;;;;GAKG;AACH,MAAM,UAAU,GAAG,CACjB,QAAgB,EAChB,iBAAqC;IAErC,OAAO,UAAU,CACf;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,gBAAgB,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC;SAC9C;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC"}
|
|
@@ -1,22 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.Min = Min;
|
|
4
|
-
const class_validator_1 = require("class-validator");
|
|
5
|
-
const utils_1 = require("../../utils");
|
|
1
|
+
import { ValidateBy } from "class-validator";
|
|
2
|
+
import { buildI18nMessage } from "../../utils/index.js";
|
|
6
3
|
/**
|
|
7
4
|
* Validates that the property value is greater than or equal to the specified minimum.
|
|
8
5
|
* @param minValue - The minimum allowed value
|
|
9
6
|
* @param validationOptions - Optional class-validator validation options
|
|
10
7
|
* @returns Property decorator
|
|
11
8
|
*/
|
|
12
|
-
function Min(minValue, validationOptions) {
|
|
13
|
-
return
|
|
9
|
+
export function Min(minValue, validationOptions) {
|
|
10
|
+
return ValidateBy({
|
|
14
11
|
name: "min",
|
|
15
12
|
constraints: [minValue],
|
|
16
13
|
validator: {
|
|
17
14
|
validate: (value, args) => typeof args !== "undefined" &&
|
|
18
15
|
Number(value) >= Number(args.constraints[0]),
|
|
19
|
-
defaultMessage:
|
|
16
|
+
defaultMessage: buildI18nMessage(() => "min"),
|
|
20
17
|
},
|
|
21
18
|
}, validationOptions);
|
|
22
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"min.decorator.js","sourceRoot":"","sources":["../../../src/decorators/number/min.decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"min.decorator.js","sourceRoot":"","sources":["../../../src/decorators/number/min.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA0B,MAAM,iBAAiB,CAAC;AAErE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD;;;;;GAKG;AACH,MAAM,UAAU,GAAG,CACjB,QAAgB,EAChB,iBAAqC;IAErC,OAAO,UAAU,CACf;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,gBAAgB,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC;SAC9C;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC"}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.Comparator = void 0;
|
|
4
|
-
exports.ValidateCompareNumber = ValidateCompareNumber;
|
|
5
|
-
const i18n_1 = require("@nest-boot/i18n");
|
|
6
|
-
const class_validator_1 = require("class-validator");
|
|
1
|
+
import { t } from "@nest-boot/i18n";
|
|
2
|
+
import { registerDecorator, } from "class-validator";
|
|
7
3
|
/** Comparison operators for number validation. */
|
|
8
|
-
var Comparator;
|
|
4
|
+
export var Comparator;
|
|
9
5
|
(function (Comparator) {
|
|
10
6
|
/** Equal to. */
|
|
11
7
|
Comparator["EQ"] = "EQ";
|
|
@@ -17,7 +13,7 @@ var Comparator;
|
|
|
17
13
|
Comparator["LT"] = "LT";
|
|
18
14
|
/** Less than or equal to. */
|
|
19
15
|
Comparator["LTE"] = "LTE";
|
|
20
|
-
})(Comparator || (
|
|
16
|
+
})(Comparator || (Comparator = {}));
|
|
21
17
|
/**
|
|
22
18
|
* Validates that a numeric property satisfies a comparison against another property's value.
|
|
23
19
|
* @param comparator - The comparison operator to use
|
|
@@ -25,10 +21,10 @@ var Comparator;
|
|
|
25
21
|
* @param validationOptions - Optional class-validator validation options
|
|
26
22
|
* @returns Property decorator
|
|
27
23
|
*/
|
|
28
|
-
function ValidateCompareNumber(comparator, compareProperty, validationOptions) {
|
|
24
|
+
export function ValidateCompareNumber(comparator, compareProperty, validationOptions) {
|
|
29
25
|
return (target, propertyName) => {
|
|
30
26
|
if (typeof propertyName === "string") {
|
|
31
|
-
|
|
27
|
+
registerDecorator({
|
|
32
28
|
name: "isGreaterThanOrEqual",
|
|
33
29
|
target: target.constructor,
|
|
34
30
|
propertyName,
|
|
@@ -63,10 +59,10 @@ function ValidateCompareNumber(comparator, compareProperty, validationOptions) {
|
|
|
63
59
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
64
60
|
const { property, constraints } = args;
|
|
65
61
|
const [innerComparator, innerCompareProperty] = constraints;
|
|
66
|
-
return
|
|
62
|
+
return t(`validation:is-${innerComparator.toLowerCase()}`, {
|
|
67
63
|
...args,
|
|
68
|
-
property:
|
|
69
|
-
compareProperty:
|
|
64
|
+
property: t(`property:${property}`),
|
|
65
|
+
compareProperty: t(`property:${innerCompareProperty}`),
|
|
70
66
|
});
|
|
71
67
|
},
|
|
72
68
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-compare-number.decorator.js","sourceRoot":"","sources":["../../../src/decorators/number/validate-compare-number.decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validate-compare-number.decorator.js","sourceRoot":"","sources":["../../../src/decorators/number/validate-compare-number.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,iBAAiB,CAAC;AACpC,OAAO,EACL,iBAAiB,GAGlB,MAAM,iBAAiB,CAAC;AAEzB,kDAAkD;AAClD,MAAM,CAAN,IAAY,UAWX;AAXD,WAAY,UAAU;IACpB,gBAAgB;IAChB,uBAAS,CAAA;IACT,oBAAoB;IACpB,uBAAS,CAAA;IACT,gCAAgC;IAChC,yBAAW,CAAA;IACX,iBAAiB;IACjB,uBAAS,CAAA;IACT,6BAA6B;IAC7B,yBAAW,CAAA;AACb,CAAC,EAXW,UAAU,KAAV,UAAU,QAWrB;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CACnC,UAAsB,EACtB,eAAuB,EACvB,iBAAqC;IAErC,OAAO,CAAC,MAAc,EAAE,YAA6B,EAAE,EAAE;QACvD,IAAI,OAAO,YAAY,KAAK,QAAQ,EAAE,CAAC;YACrC,iBAAiB,CAAC;gBAChB,IAAI,EAAE,sBAAsB;gBAC5B,MAAM,EAAE,MAAM,CAAC,WAAW;gBAC1B,YAAY;gBACZ,WAAW,EAAE,CAAC,UAAU,EAAE,eAAe,CAAC;gBAC1C,OAAO,EAAE,iBAAiB;gBAC1B,SAAS,EAAE;oBACT,QAAQ,CAAC,KAAc,EAAE,IAAyB;wBAChD,IAAI,OAAO,IAAI,KAAK,WAAW,EAAE,CAAC;4BAChC,OAAO,KAAK,CAAC;wBACf,CAAC;wBAED,MAAM,CAAC,eAAe,EAAE,oBAAoB,CAAC,GAC3C,IAAI,CAAC,WAAmC,CAAC;wBAE3C,MAAM,YAAY,GAAI,IAAI,CAAC,MAAc,CAAC,oBAAoB,CAAC,CAAC;wBAEhE,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,KAAK,IAAI,EAAE,CAAC;4BACxD,OAAO,IAAI,CAAC;wBACd,CAAC;wBAED,QAAQ,eAAe,EAAE,CAAC;4BACxB,KAAK,UAAU,CAAC,EAAE;gCAChB,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,MAAM,CAAC,YAAY,CAAC,CAAC;4BAChD,KAAK,UAAU,CAAC,EAAE;gCAChB,OAAO,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;4BAC9C,KAAK,UAAU,CAAC,GAAG;gCACjB,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,YAAY,CAAC,CAAC;4BAC/C,KAAK,UAAU,CAAC,EAAE;gCAChB,OAAO,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;4BAC9C,KAAK,UAAU,CAAC,GAAG;gCACjB,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,YAAY,CAAC,CAAC;4BAC/C;gCACE,OAAO,KAAK,CAAC;wBACjB,CAAC;oBACH,CAAC;oBACD,cAAc,CAAC,IAAI;wBACjB,oEAAoE;wBACpE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,IAAK,CAAC;wBACxC,MAAM,CAAC,eAAe,EAAE,oBAAoB,CAAC,GAAG,WAG/C,CAAC;wBAEF,OAAO,CAAC,CAAC,iBAAiB,eAAe,CAAC,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;QACL,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.IsDomain = IsDomain;
|
|
4
|
-
const class_validator_1 = require("class-validator");
|
|
5
|
-
const utils_1 = require("../../utils");
|
|
1
|
+
import { ValidateBy } from "class-validator";
|
|
2
|
+
import { buildI18nMessage } from "../../utils/index.js";
|
|
6
3
|
/**
|
|
7
4
|
* Validates that the string value is a valid domain name.
|
|
8
5
|
* @param validationOptions - Optional class-validator validation options
|
|
9
6
|
* @returns Property decorator
|
|
10
7
|
*/
|
|
11
|
-
function IsDomain(validationOptions) {
|
|
12
|
-
return
|
|
8
|
+
export function IsDomain(validationOptions) {
|
|
9
|
+
return ValidateBy({
|
|
13
10
|
name: "IsDomain",
|
|
14
11
|
validator: {
|
|
15
12
|
validate: (value) => typeof value === "string" &&
|
|
16
13
|
/^(?=^.{3,255}$)[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+$/.test(value),
|
|
17
|
-
defaultMessage:
|
|
14
|
+
defaultMessage: buildI18nMessage(() => "is-domain"),
|
|
18
15
|
},
|
|
19
16
|
}, validationOptions);
|
|
20
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-domain.decorator.js","sourceRoot":"","sources":["../../../src/decorators/string/is-domain.decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"is-domain.decorator.js","sourceRoot":"","sources":["../../../src/decorators/string/is-domain.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA0B,MAAM,iBAAiB,CAAC;AAErE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CACtB,iBAAqC;IAErC,OAAO,UAAU,CACf;QACE,IAAI,EAAE,UAAU;QAChB,SAAS,EAAE;YACT,QAAQ,EAAE,CAAC,KAAK,EAAW,EAAE,CAC3B,OAAO,KAAK,KAAK,QAAQ;gBACzB,iFAAiF,CAAC,IAAI,CACpF,KAAK,CACN;YACH,cAAc,EAAE,gBAAgB,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC;SACpD;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC"}
|
|
@@ -1,34 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.IS_EMAIL = void 0;
|
|
7
|
-
exports.isEmail = isEmail;
|
|
8
|
-
exports.IsEmail = IsEmail;
|
|
9
|
-
const class_validator_1 = require("class-validator");
|
|
10
|
-
const isEmail_1 = __importDefault(require("validator/lib/isEmail"));
|
|
11
|
-
const utils_1 = require("../../utils");
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { ValidateBy } from "class-validator";
|
|
3
|
+
import { buildI18nMessage } from "../../utils/index.js";
|
|
4
|
+
const require = createRequire(import.meta.url);
|
|
5
|
+
const isEmailValidator = require("validator/lib/isEmail.js");
|
|
12
6
|
/** Validation name constant for the IsEmail validator. */
|
|
13
|
-
|
|
7
|
+
export const IS_EMAIL = "isEmail";
|
|
14
8
|
/**
|
|
15
9
|
* Checks if the string is an email.
|
|
16
10
|
* If given value is not a string, then it returns false.
|
|
17
11
|
*/
|
|
18
|
-
function isEmail(value, options) {
|
|
19
|
-
return typeof value === "string" && (
|
|
12
|
+
export function isEmail(value, options) {
|
|
13
|
+
return typeof value === "string" && isEmailValidator(value, options);
|
|
20
14
|
}
|
|
21
15
|
/**
|
|
22
16
|
* Checks if the string is an email.
|
|
23
17
|
* If given value is not a string, then it returns false.
|
|
24
18
|
*/
|
|
25
|
-
function IsEmail(options, validationOptions) {
|
|
26
|
-
return
|
|
27
|
-
name:
|
|
19
|
+
export function IsEmail(options, validationOptions) {
|
|
20
|
+
return ValidateBy({
|
|
21
|
+
name: IS_EMAIL,
|
|
28
22
|
constraints: [options],
|
|
29
23
|
validator: {
|
|
30
24
|
validate: (value, args) => typeof args !== "undefined" && isEmail(value, args.constraints[0]),
|
|
31
|
-
defaultMessage:
|
|
25
|
+
defaultMessage: buildI18nMessage(() => "is-email"),
|
|
32
26
|
},
|
|
33
27
|
}, validationOptions);
|
|
34
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-email.decorator.js","sourceRoot":"","sources":["../../../src/decorators/string/is-email.decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"is-email.decorator.js","sourceRoot":"","sources":["../../../src/decorators/string/is-email.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,UAAU,EAA0B,MAAM,iBAAiB,CAAC;AAGrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,gBAAgB,GAAG,OAAO,CAAC,0BAA0B,CAG/C,CAAC;AAEb,0DAA0D;AAC1D,MAAM,CAAC,MAAM,QAAQ,GAAG,SAAS,CAAC;AAElC;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,KAAc,EAAE,OAAwB;IAC9D,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,gBAAgB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AACvE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,OAAO,CACrB,OAAwB,EACxB,iBAAqC;IAErC,OAAO,UAAU,CACf;QACE,IAAI,EAAE,QAAQ;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,gBAAgB,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC;SACnD;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ValidationOptions } from "class-validator";
|
|
2
|
-
import { IsNumericOptions } from "validator";
|
|
2
|
+
import { type IsNumericOptions } from "validator";
|
|
3
3
|
/** Validation name constant for the IsNumberString validator. */
|
|
4
4
|
export declare const IS_NUMBER_STRING = "isNumberString";
|
|
5
5
|
/**
|
|
@@ -1,35 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.IS_NUMBER_STRING = void 0;
|
|
7
|
-
exports.isNumberString = isNumberString;
|
|
8
|
-
exports.IsNumberString = IsNumberString;
|
|
9
|
-
const class_validator_1 = require("class-validator");
|
|
10
|
-
const isNumeric_1 = __importDefault(require("validator/lib/isNumeric"));
|
|
11
|
-
const utils_1 = require("../../utils");
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { ValidateBy } from "class-validator";
|
|
3
|
+
import { buildI18nMessage } from "../../utils/index.js";
|
|
4
|
+
const require = createRequire(import.meta.url);
|
|
5
|
+
const isNumericValidator = require("validator/lib/isNumeric.js");
|
|
12
6
|
/** Validation name constant for the IsNumberString validator. */
|
|
13
|
-
|
|
7
|
+
export const IS_NUMBER_STRING = "isNumberString";
|
|
14
8
|
/**
|
|
15
9
|
* Checks if the string is numeric.
|
|
16
10
|
* If given value is not a string, then it returns false.
|
|
17
11
|
*/
|
|
18
|
-
function isNumberString(value, options) {
|
|
19
|
-
return typeof value === "string" && (
|
|
12
|
+
export function isNumberString(value, options) {
|
|
13
|
+
return typeof value === "string" && isNumericValidator(value, options);
|
|
20
14
|
}
|
|
21
15
|
/**
|
|
22
16
|
* Checks if the string is numeric.
|
|
23
17
|
* If given value is not a string, then it returns false.
|
|
24
18
|
*/
|
|
25
|
-
function IsNumberString(options, validationOptions) {
|
|
26
|
-
return
|
|
27
|
-
name:
|
|
19
|
+
export function IsNumberString(options, validationOptions) {
|
|
20
|
+
return ValidateBy({
|
|
21
|
+
name: IS_NUMBER_STRING,
|
|
28
22
|
constraints: [options],
|
|
29
23
|
validator: {
|
|
30
24
|
validate: (value, args) => typeof args !== "undefined" &&
|
|
31
25
|
isNumberString(value, args.constraints[0]),
|
|
32
|
-
defaultMessage:
|
|
26
|
+
defaultMessage: buildI18nMessage(() => "is-number-string"),
|
|
33
27
|
},
|
|
34
28
|
}, validationOptions);
|
|
35
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-number-string.decorator.js","sourceRoot":"","sources":["../../../src/decorators/string/is-number-string.decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"is-number-string.decorator.js","sourceRoot":"","sources":["../../../src/decorators/string/is-number-string.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,UAAU,EAA0B,MAAM,iBAAiB,CAAC;AAGrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,kBAAkB,GAAG,OAAO,CAAC,4BAA4B,CAGnD,CAAC;AAEb,iEAAiE;AACjE,MAAM,CAAC,MAAM,gBAAgB,GAAG,gBAAgB,CAAC;AAEjD;;;GAGG;AACH,MAAM,UAAU,cAAc,CAC5B,KAAc,EACd,OAA0B;IAE1B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,kBAAkB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AACzE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAC5B,OAA0B,EAC1B,iBAAqC;IAErC,OAAO,UAAU,CACf;QACE,IAAI,EAAE,gBAAgB;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,gBAAgB,CAAC,GAAG,EAAE,CAAC,kBAAkB,CAAC;SAC3D;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC"}
|
|
@@ -1,23 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.IsTimezone = IsTimezone;
|
|
7
|
-
const class_validator_1 = require("class-validator");
|
|
8
|
-
const moment_timezone_1 = __importDefault(require("moment-timezone"));
|
|
9
|
-
const utils_1 = require("../../utils");
|
|
1
|
+
import { ValidateBy } from "class-validator";
|
|
2
|
+
import moment from "moment-timezone";
|
|
3
|
+
import { buildI18nMessage } from "../../utils/index.js";
|
|
10
4
|
/**
|
|
11
5
|
* Validates that the string value is a valid IANA timezone identifier.
|
|
12
6
|
* @param validationOptions - Optional class-validator validation options
|
|
13
7
|
* @returns Property decorator
|
|
14
8
|
*/
|
|
15
|
-
function IsTimezone(validationOptions) {
|
|
16
|
-
return
|
|
9
|
+
export function IsTimezone(validationOptions) {
|
|
10
|
+
return ValidateBy({
|
|
17
11
|
name: "isTimezone",
|
|
18
12
|
validator: {
|
|
19
|
-
validate: (value) => typeof value === "string" && !(
|
|
20
|
-
defaultMessage:
|
|
13
|
+
validate: (value) => typeof value === "string" && !(moment.tz.zone(value) == null),
|
|
14
|
+
defaultMessage: buildI18nMessage(() => "is-timezone"),
|
|
21
15
|
},
|
|
22
16
|
}, validationOptions);
|
|
23
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-timezone.decorator.js","sourceRoot":"","sources":["../../../src/decorators/string/is-timezone.decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"is-timezone.decorator.js","sourceRoot":"","sources":["../../../src/decorators/string/is-timezone.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA0B,MAAM,iBAAiB,CAAC;AACrE,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD;;;;GAIG;AACH,MAAM,UAAU,UAAU,CACxB,iBAAqC;IAErC,OAAO,UAAU,CACf;QACE,IAAI,EAAE,YAAY;QAClB,SAAS,EAAE;YACT,QAAQ,EAAE,CAAC,KAAK,EAAW,EAAE,CAC3B,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC;YAC/D,cAAc,EAAE,gBAAgB,CAAC,GAAG,EAAE,CAAC,aAAa,CAAC;SACtD;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC"}
|