@nest-boot/validator 7.3.7 → 8.0.0-beta.1
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.d.ts +0 -8
- package/dist/decorators/common/array-length.decorator.js +12 -25
- 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 -34
- package/dist/decorators/index.js.map +1 -1
- package/dist/decorators/number/is-greater-than-or-equal.decorator.d.ts +0 -6
- package/dist/decorators/number/is-greater-than-or-equal.decorator.js +3 -12
- package/dist/decorators/number/is-greater-than-or-equal.decorator.js.map +1 -1
- package/dist/decorators/number/is-greater-than.decorator.d.ts +0 -6
- package/dist/decorators/number/is-greater-than.decorator.js +3 -12
- package/dist/decorators/number/is-greater-than.decorator.js.map +1 -1
- package/dist/decorators/number/is-less-than-or-equal.decorator.d.ts +0 -6
- package/dist/decorators/number/is-less-than-or-equal.decorator.js +3 -12
- package/dist/decorators/number/is-less-than-or-equal.decorator.js.map +1 -1
- package/dist/decorators/number/is-less-than.decorator.d.ts +0 -6
- package/dist/decorators/number/is-less-than.decorator.js +3 -12
- package/dist/decorators/number/is-less-than.decorator.js.map +1 -1
- package/dist/decorators/number/max.decorator.d.ts +0 -6
- package/dist/decorators/number/max.decorator.js +5 -14
- package/dist/decorators/number/max.decorator.js.map +1 -1
- package/dist/decorators/number/min.decorator.d.ts +0 -6
- package/dist/decorators/number/min.decorator.js +5 -14
- package/dist/decorators/number/min.decorator.js.map +1 -1
- package/dist/decorators/number/validate-compare-number.decorator.d.ts +0 -13
- package/dist/decorators/number/validate-compare-number.decorator.js +9 -27
- package/dist/decorators/number/validate-compare-number.decorator.js.map +1 -1
- package/dist/decorators/string/is-domain.decorator.d.ts +0 -5
- package/dist/decorators/string/is-domain.decorator.js +5 -13
- package/dist/decorators/string/is-domain.decorator.js.map +1 -1
- package/dist/decorators/string/is-email.decorator.d.ts +1 -10
- package/dist/decorators/string/is-email.decorator.js +11 -27
- package/dist/decorators/string/is-email.decorator.js.map +1 -1
- package/dist/decorators/string/is-number-string.decorator.d.ts +1 -10
- package/dist/decorators/string/is-number-string.decorator.js +11 -27
- package/dist/decorators/string/is-number-string.decorator.js.map +1 -1
- package/dist/decorators/string/is-timezone.decorator.d.ts +0 -5
- package/dist/decorators/string/is-timezone.decorator.js +7 -18
- package/dist/decorators/string/is-timezone.decorator.js.map +1 -1
- package/dist/decorators/string/is-url.decorator.d.ts +1 -10
- package/dist/decorators/string/is-url.decorator.js +11 -27
- package/dist/decorators/string/is-url.decorator.js.map +1 -1
- package/dist/decorators/string/length.decorator.d.ts +0 -9
- package/dist/decorators/string/length.decorator.js +11 -27
- package/dist/decorators/string/length.decorator.js.map +1 -1
- package/dist/decorators/type-check/is-date.decorator.d.ts +0 -7
- package/dist/decorators/type-check/is-date.decorator.js +8 -20
- package/dist/decorators/type-check/is-date.decorator.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -22
- package/dist/index.js.map +1 -1
- package/dist/utils/build-i18n-message.d.ts +0 -10
- package/dist/utils/build-i18n-message.js +4 -17
- 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 +34 -22
- package/dist/decorators/common/array-length.decorator.spec.d.ts +0 -1
- package/dist/decorators/common/array-length.decorator.spec.js +0 -46
- package/dist/decorators/common/array-length.decorator.spec.js.map +0 -1
- package/dist/decorators/number/number-decorators.spec.d.ts +0 -1
- package/dist/decorators/number/number-decorators.spec.js +0 -99
- package/dist/decorators/number/number-decorators.spec.js.map +0 -1
- package/dist/decorators/string/length.decorator.spec.d.ts +0 -1
- package/dist/decorators/string/length.decorator.spec.js +0 -51
- package/dist/decorators/string/length.decorator.spec.js.map +0 -1
- package/dist/decorators/string/string-decorators.spec.d.ts +0 -1
- package/dist/decorators/string/string-decorators.spec.js +0 -105
- package/dist/decorators/string/string-decorators.spec.js.map +0 -1
- package/dist/tsconfig.build.tsbuildinfo +0 -1
|
@@ -1,34 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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");
|
|
12
|
-
/** Validation name constant for the IsEmail validator. */
|
|
13
|
-
exports.IS_EMAIL = "isEmail";
|
|
14
|
-
/**
|
|
15
|
-
* Checks if the string is an email.
|
|
16
|
-
* If given value is not a string, then it returns false.
|
|
17
|
-
*/
|
|
18
|
-
function isEmail(value, options) {
|
|
19
|
-
return typeof value === "string" && (0, isEmail_1.default)(value, options);
|
|
1
|
+
import { ValidateBy } from "class-validator";
|
|
2
|
+
import isEmailModule from "validator/lib/isEmail.js";
|
|
3
|
+
import { buildI18nMessage } from "../../utils/index.js";
|
|
4
|
+
const isEmailValidator = isEmailModule;
|
|
5
|
+
export const IS_EMAIL = "isEmail";
|
|
6
|
+
export function isEmail(value, options) {
|
|
7
|
+
return typeof value === "string" && isEmailValidator(value, options);
|
|
20
8
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
*/
|
|
25
|
-
function IsEmail(options, validationOptions) {
|
|
26
|
-
return (0, class_validator_1.ValidateBy)({
|
|
27
|
-
name: exports.IS_EMAIL,
|
|
9
|
+
export function IsEmail(options, validationOptions) {
|
|
10
|
+
return ValidateBy({
|
|
11
|
+
name: IS_EMAIL,
|
|
28
12
|
constraints: [options],
|
|
29
13
|
validator: {
|
|
30
14
|
validate: (value, args) => typeof args !== "undefined" && isEmail(value, args.constraints[0]),
|
|
31
|
-
defaultMessage:
|
|
15
|
+
defaultMessage: buildI18nMessage(() => "is-email"),
|
|
32
16
|
},
|
|
33
17
|
}, validationOptions);
|
|
34
18
|
}
|
|
@@ -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,UAAU,EAA0B,MAAM,iBAAiB,CAAC;AAErE,OAAO,aAAa,MAAM,0BAA0B,CAAC;AAErD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,MAAM,gBAAgB,GAAG,aAGb,CAAC;AAGb,MAAM,CAAC,MAAM,QAAQ,GAAG,SAAS,CAAC;AAMlC,MAAM,UAAU,OAAO,CAAC,KAAc,EAAE,OAAwB;IAC9D,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,gBAAgB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AACvE,CAAC;AAMD,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,14 +1,5 @@
|
|
|
1
1
|
import { type ValidationOptions } from "class-validator";
|
|
2
|
-
import { IsNumericOptions } from "validator";
|
|
3
|
-
/** Validation name constant for the IsNumberString validator. */
|
|
2
|
+
import { type IsNumericOptions } from "validator";
|
|
4
3
|
export declare const IS_NUMBER_STRING = "isNumberString";
|
|
5
|
-
/**
|
|
6
|
-
* Checks if the string is numeric.
|
|
7
|
-
* If given value is not a string, then it returns false.
|
|
8
|
-
*/
|
|
9
4
|
export declare function isNumberString(value: unknown, options?: IsNumericOptions): boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Checks if the string is numeric.
|
|
12
|
-
* If given value is not a string, then it returns false.
|
|
13
|
-
*/
|
|
14
5
|
export declare function IsNumberString(options?: IsNumericOptions, validationOptions?: ValidationOptions): PropertyDecorator;
|
|
@@ -1,35 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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");
|
|
12
|
-
/** Validation name constant for the IsNumberString validator. */
|
|
13
|
-
exports.IS_NUMBER_STRING = "isNumberString";
|
|
14
|
-
/**
|
|
15
|
-
* Checks if the string is numeric.
|
|
16
|
-
* If given value is not a string, then it returns false.
|
|
17
|
-
*/
|
|
18
|
-
function isNumberString(value, options) {
|
|
19
|
-
return typeof value === "string" && (0, isNumeric_1.default)(value, options);
|
|
1
|
+
import { ValidateBy } from "class-validator";
|
|
2
|
+
import isNumericModule from "validator/lib/isNumeric.js";
|
|
3
|
+
import { buildI18nMessage } from "../../utils/index.js";
|
|
4
|
+
const isNumericValidator = isNumericModule;
|
|
5
|
+
export const IS_NUMBER_STRING = "isNumberString";
|
|
6
|
+
export function isNumberString(value, options) {
|
|
7
|
+
return typeof value === "string" && isNumericValidator(value, options);
|
|
20
8
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
*/
|
|
25
|
-
function IsNumberString(options, validationOptions) {
|
|
26
|
-
return (0, class_validator_1.ValidateBy)({
|
|
27
|
-
name: exports.IS_NUMBER_STRING,
|
|
9
|
+
export function IsNumberString(options, validationOptions) {
|
|
10
|
+
return ValidateBy({
|
|
11
|
+
name: IS_NUMBER_STRING,
|
|
28
12
|
constraints: [options],
|
|
29
13
|
validator: {
|
|
30
14
|
validate: (value, args) => typeof args !== "undefined" &&
|
|
31
15
|
isNumberString(value, args.constraints[0]),
|
|
32
|
-
defaultMessage:
|
|
16
|
+
defaultMessage: buildI18nMessage(() => "is-number-string"),
|
|
33
17
|
},
|
|
34
18
|
}, validationOptions);
|
|
35
19
|
}
|
|
@@ -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,UAAU,EAA0B,MAAM,iBAAiB,CAAC;AAErE,OAAO,eAAe,MAAM,4BAA4B,CAAC;AAEzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,MAAM,kBAAkB,GAAG,eAGf,CAAC;AAGb,MAAM,CAAC,MAAM,gBAAgB,GAAG,gBAAgB,CAAC;AAMjD,MAAM,UAAU,cAAc,CAC5B,KAAc,EACd,OAA0B;IAE1B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,kBAAkB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AACzE,CAAC;AAMD,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,7 +1,2 @@
|
|
|
1
1
|
import { type ValidationOptions } from "class-validator";
|
|
2
|
-
/**
|
|
3
|
-
* Validates that the string value is a valid IANA timezone identifier.
|
|
4
|
-
* @param validationOptions - Optional class-validator validation options
|
|
5
|
-
* @returns Property decorator
|
|
6
|
-
*/
|
|
7
2
|
export declare function IsTimezone(validationOptions?: ValidationOptions): PropertyDecorator;
|
|
@@ -1,23 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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");
|
|
10
|
-
/**
|
|
11
|
-
* Validates that the string value is a valid IANA timezone identifier.
|
|
12
|
-
* @param validationOptions - Optional class-validator validation options
|
|
13
|
-
* @returns Property decorator
|
|
14
|
-
*/
|
|
15
|
-
function IsTimezone(validationOptions) {
|
|
16
|
-
return (0, class_validator_1.ValidateBy)({
|
|
1
|
+
import { ValidateBy } from "class-validator";
|
|
2
|
+
import moment from "moment-timezone";
|
|
3
|
+
import { buildI18nMessage } from "../../utils/index.js";
|
|
4
|
+
export function IsTimezone(validationOptions) {
|
|
5
|
+
return ValidateBy({
|
|
17
6
|
name: "isTimezone",
|
|
18
7
|
validator: {
|
|
19
|
-
validate: (value) => typeof value === "string" && !(
|
|
20
|
-
defaultMessage:
|
|
8
|
+
validate: (value) => typeof value === "string" && !(moment.tz.zone(value) == null),
|
|
9
|
+
defaultMessage: buildI18nMessage(() => "is-timezone"),
|
|
21
10
|
},
|
|
22
11
|
}, validationOptions);
|
|
23
12
|
}
|
|
@@ -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;AAOxD,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"}
|
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
import { type ValidationOptions } from "class-validator";
|
|
2
|
-
import { IsURLOptions } from "validator";
|
|
3
|
-
/** Validation name constant for the IsUrl validator. */
|
|
2
|
+
import { type IsURLOptions } from "validator";
|
|
4
3
|
export declare const IS_URL = "isUrl";
|
|
5
|
-
/**
|
|
6
|
-
* Checks if the string is an url.
|
|
7
|
-
* If given value is not a string, then it returns false.
|
|
8
|
-
*/
|
|
9
4
|
export declare function isURL(value: string, options?: IsURLOptions): boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Checks if the string is an url.
|
|
12
|
-
* If given value is not a string, then it returns false.
|
|
13
|
-
*/
|
|
14
5
|
export declare function IsUrl(options?: IsURLOptions, validationOptions?: ValidationOptions): PropertyDecorator;
|
|
@@ -1,34 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
exports.IsUrl = IsUrl;
|
|
9
|
-
const class_validator_1 = require("class-validator");
|
|
10
|
-
const isURL_1 = __importDefault(require("validator/lib/isURL"));
|
|
11
|
-
const utils_1 = require("../../utils");
|
|
12
|
-
/** Validation name constant for the IsUrl validator. */
|
|
13
|
-
exports.IS_URL = "isUrl";
|
|
14
|
-
/**
|
|
15
|
-
* Checks if the string is an url.
|
|
16
|
-
* If given value is not a string, then it returns false.
|
|
17
|
-
*/
|
|
18
|
-
function isURL(value, options) {
|
|
19
|
-
return typeof value === "string" && (0, isURL_1.default)(value, options);
|
|
1
|
+
import { ValidateBy } from "class-validator";
|
|
2
|
+
import isUrlModule from "validator/lib/isURL.js";
|
|
3
|
+
import { buildI18nMessage } from "../../utils/index.js";
|
|
4
|
+
const isUrlValidator = isUrlModule;
|
|
5
|
+
export const IS_URL = "isUrl";
|
|
6
|
+
export function isURL(value, options) {
|
|
7
|
+
return typeof value === "string" && isUrlValidator(value, options);
|
|
20
8
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
*/
|
|
25
|
-
function IsUrl(options, validationOptions) {
|
|
26
|
-
return (0, class_validator_1.ValidateBy)({
|
|
27
|
-
name: exports.IS_URL,
|
|
9
|
+
export function IsUrl(options, validationOptions) {
|
|
10
|
+
return ValidateBy({
|
|
11
|
+
name: IS_URL,
|
|
28
12
|
constraints: [options],
|
|
29
13
|
validator: {
|
|
30
14
|
validate: (value, args) => typeof args !== "undefined" && isURL(value, args.constraints[0]),
|
|
31
|
-
defaultMessage:
|
|
15
|
+
defaultMessage: buildI18nMessage(() => "is-url"),
|
|
32
16
|
},
|
|
33
17
|
}, validationOptions);
|
|
34
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-url.decorator.js","sourceRoot":"","sources":["../../../src/decorators/string/is-url.decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"is-url.decorator.js","sourceRoot":"","sources":["../../../src/decorators/string/is-url.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA0B,MAAM,iBAAiB,CAAC;AAErE,OAAO,WAAW,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,MAAM,cAAc,GAAG,WAGX,CAAC;AAGb,MAAM,CAAC,MAAM,MAAM,GAAG,OAAO,CAAC;AAM9B,MAAM,UAAU,KAAK,CAAC,KAAa,EAAE,OAAsB;IACzD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AACrE,CAAC;AAMD,MAAM,UAAU,KAAK,CACnB,OAAsB,EACtB,iBAAqC;IAErC,OAAO,UAAU,CACf;QACE,IAAI,EAAE,MAAM;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,gBAAgB,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC;SACjD;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC"}
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
import { type ValidationOptions } from "class-validator";
|
|
2
|
-
/** Validation name constant for the Length validator. */
|
|
3
2
|
export declare const IS_LENGTH = "isLength";
|
|
4
|
-
/**
|
|
5
|
-
* Checks if the string's length falls in a range. Note: this function takes into account surrogate pairs.
|
|
6
|
-
* If given value is not a string, then it returns false.
|
|
7
|
-
*/
|
|
8
3
|
export declare function length(value: unknown, min: number, max?: number): boolean;
|
|
9
|
-
/**
|
|
10
|
-
* Checks if the string's length falls in a range. Note: this function takes into account surrogate pairs.
|
|
11
|
-
* If given value is not a string, then it returns false.
|
|
12
|
-
*/
|
|
13
4
|
export declare function Length(min: number, max?: number, validationOptions?: ValidationOptions): PropertyDecorator;
|
|
@@ -1,35 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
exports.Length = Length;
|
|
9
|
-
const class_validator_1 = require("class-validator");
|
|
10
|
-
const isLength_1 = __importDefault(require("validator/lib/isLength"));
|
|
11
|
-
const build_i18n_message_1 = require("../../utils/build-i18n-message");
|
|
12
|
-
/** Validation name constant for the Length validator. */
|
|
13
|
-
exports.IS_LENGTH = "isLength";
|
|
14
|
-
/**
|
|
15
|
-
* Checks if the string's length falls in a range. Note: this function takes into account surrogate pairs.
|
|
16
|
-
* If given value is not a string, then it returns false.
|
|
17
|
-
*/
|
|
18
|
-
function length(value, min, max) {
|
|
19
|
-
return typeof value === "string" && (0, isLength_1.default)(value, { min, max });
|
|
1
|
+
import { ValidateBy } from "class-validator";
|
|
2
|
+
import isLengthModule from "validator/lib/isLength.js";
|
|
3
|
+
import { buildI18nMessage } from "../../utils/build-i18n-message.js";
|
|
4
|
+
const isLengthValidator = isLengthModule;
|
|
5
|
+
export const IS_LENGTH = "isLength";
|
|
6
|
+
export function length(value, min, max) {
|
|
7
|
+
return typeof value === "string" && isLengthValidator(value, { min, max });
|
|
20
8
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
*/
|
|
25
|
-
function Length(min, max, validationOptions) {
|
|
26
|
-
return (0, class_validator_1.ValidateBy)({
|
|
27
|
-
name: exports.IS_LENGTH,
|
|
9
|
+
export function Length(min, max, validationOptions) {
|
|
10
|
+
return ValidateBy({
|
|
11
|
+
name: IS_LENGTH,
|
|
28
12
|
constraints: [min, max],
|
|
29
13
|
validator: {
|
|
30
14
|
validate: (value, args) => typeof args !== "undefined" &&
|
|
31
15
|
length(value, args.constraints[0], args.constraints[1]),
|
|
32
|
-
defaultMessage:
|
|
16
|
+
defaultMessage: buildI18nMessage((args) => {
|
|
33
17
|
if (typeof args !== "undefined") {
|
|
34
18
|
const isMinLength = args.constraints[0] !== null && args.constraints[0] !== undefined;
|
|
35
19
|
const isMaxLength = args.constraints[1] !== null && args.constraints[1] !== undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"length.decorator.js","sourceRoot":"","sources":["../../../src/decorators/string/length.decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"length.decorator.js","sourceRoot":"","sources":["../../../src/decorators/string/length.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA0B,MAAM,iBAAiB,CAAC;AACrE,OAAO,cAAc,MAAM,2BAA2B,CAAC;AAEvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAErE,MAAM,iBAAiB,GAAG,cAGd,CAAC;AAGb,MAAM,CAAC,MAAM,SAAS,GAAG,UAAU,CAAC;AAMpC,MAAM,UAAU,MAAM,CAAC,KAAc,EAAE,GAAW,EAAE,GAAY;IAC9D,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,iBAAiB,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;AAC7E,CAAC;AAMD,MAAM,UAAU,MAAM,CACpB,GAAW,EACX,GAAY,EACZ,iBAAqC;IAErC,OAAO,UAAU,CACf;QACE,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC;QACvB,SAAS,EAAE;YACT,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CACjC,OAAO,IAAI,KAAK,WAAW;gBAC3B,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YACzD,cAAc,EAAE,gBAAgB,CAAC,CAAC,IAAI,EAAE,EAAE;gBACxC,IAAI,OAAO,IAAI,KAAK,WAAW,EAAE,CAAC;oBAChC,MAAM,WAAW,GACf,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC;oBACpE,MAAM,WAAW,GACf,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC;oBAEpE,IAAI,WAAW,IAAI,CAAC,WAAW,EAAE,CAAC;wBAChC,OAAO,YAAY,CAAC;oBACtB,CAAC;gBACH,CAAC;gBAED,OAAO,gBAAgB,CAAC;YAC1B,CAAC,CAAC;SACH;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC"}
|
|
@@ -1,11 +1,4 @@
|
|
|
1
1
|
import { type ValidationOptions } from "class-validator";
|
|
2
|
-
/** Validation name constant for the IsDate validator. */
|
|
3
2
|
export declare const IS_DATE = "isDate";
|
|
4
|
-
/**
|
|
5
|
-
* Checks if a given value is a date.
|
|
6
|
-
*/
|
|
7
3
|
export declare function isDate(value: unknown): boolean;
|
|
8
|
-
/**
|
|
9
|
-
* Checks if a value is a date.
|
|
10
|
-
*/
|
|
11
4
|
export declare function IsDate(validationOptions?: ValidationOptions): PropertyDecorator;
|
|
@@ -1,27 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
exports.IsDate = IsDate;
|
|
6
|
-
const class_validator_1 = require("class-validator");
|
|
7
|
-
const utils_1 = require("../../utils");
|
|
8
|
-
/** Validation name constant for the IsDate validator. */
|
|
9
|
-
exports.IS_DATE = "isDate";
|
|
10
|
-
/**
|
|
11
|
-
* Checks if a given value is a date.
|
|
12
|
-
*/
|
|
13
|
-
function isDate(value) {
|
|
1
|
+
import { ValidateBy } from "class-validator";
|
|
2
|
+
import { buildI18nMessage } from "../../utils/index.js";
|
|
3
|
+
export const IS_DATE = "isDate";
|
|
4
|
+
export function isDate(value) {
|
|
14
5
|
return value instanceof Date && !Number.isNaN(value.getTime());
|
|
15
6
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
function IsDate(validationOptions) {
|
|
20
|
-
return (0, class_validator_1.ValidateBy)({
|
|
21
|
-
name: exports.IS_DATE,
|
|
7
|
+
export function IsDate(validationOptions) {
|
|
8
|
+
return ValidateBy({
|
|
9
|
+
name: IS_DATE,
|
|
22
10
|
validator: {
|
|
23
11
|
validate: (value) => isDate(value),
|
|
24
|
-
defaultMessage:
|
|
12
|
+
defaultMessage: buildI18nMessage(() => "is-date"),
|
|
25
13
|
},
|
|
26
14
|
}, validationOptions);
|
|
27
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-date.decorator.js","sourceRoot":"","sources":["../../../src/decorators/type-check/is-date.decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"is-date.decorator.js","sourceRoot":"","sources":["../../../src/decorators/type-check/is-date.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA0B,MAAM,iBAAiB,CAAC;AAErE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAGxD,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC;AAKhC,MAAM,UAAU,MAAM,CAAC,KAAc;IACnC,OAAO,KAAK,YAAY,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;AACjE,CAAC;AAKD,MAAM,UAAU,MAAM,CACpB,iBAAqC;IAErC,OAAO,UAAU,CACf;QACE,IAAI,EAAE,OAAO;QACb,SAAS,EAAE;YACT,QAAQ,EAAE,CAAC,KAAK,EAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC;YAC3C,cAAc,EAAE,gBAAgB,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC;SAClD;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,23 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
exports.ValidateNested = exports.IsOptional = void 0;
|
|
18
|
-
const class_validator_1 = require("class-validator");
|
|
19
|
-
Object.defineProperty(exports, "IsOptional", { enumerable: true, get: function () { return class_validator_1.IsOptional; } });
|
|
20
|
-
Object.defineProperty(exports, "ValidateNested", { enumerable: true, get: function () { return class_validator_1.ValidateNested; } });
|
|
21
|
-
__exportStar(require("./decorators"), exports);
|
|
22
|
-
__exportStar(require("./utils"), exports);
|
|
1
|
+
import { IsOptional, ValidateNested } from "class-validator";
|
|
2
|
+
export * from "./decorators/index.js";
|
|
3
|
+
export * from "./utils/index.js";
|
|
4
|
+
export { IsOptional, ValidateNested };
|
|
23
5
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAE7D,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AAGjC,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -1,12 +1,2 @@
|
|
|
1
1
|
import { type ValidationArguments } from "class-validator";
|
|
2
|
-
/**
|
|
3
|
-
* Creates an i18n-aware validation message factory.
|
|
4
|
-
*
|
|
5
|
-
* @remarks
|
|
6
|
-
* Wraps a callback that returns a translation key, automatically
|
|
7
|
-
* providing constraint values and property translation to the message.
|
|
8
|
-
*
|
|
9
|
-
* @param callback - Function that receives validation args and returns the translation key suffix
|
|
10
|
-
* @returns A function usable as the `defaultMessage` in class-validator decorators
|
|
11
|
-
*/
|
|
12
2
|
export declare function buildI18nMessage(callback: (args: ValidationArguments) => string): (args: ValidationArguments) => string;
|
|
@@ -1,26 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.buildI18nMessage = buildI18nMessage;
|
|
4
|
-
const i18n_1 = require("@nest-boot/i18n");
|
|
5
|
-
/**
|
|
6
|
-
* Creates an i18n-aware validation message factory.
|
|
7
|
-
*
|
|
8
|
-
* @remarks
|
|
9
|
-
* Wraps a callback that returns a translation key, automatically
|
|
10
|
-
* providing constraint values and property translation to the message.
|
|
11
|
-
*
|
|
12
|
-
* @param callback - Function that receives validation args and returns the translation key suffix
|
|
13
|
-
* @returns A function usable as the `defaultMessage` in class-validator decorators
|
|
14
|
-
*/
|
|
15
|
-
function buildI18nMessage(callback) {
|
|
1
|
+
import { t } from "@nest-boot/i18n";
|
|
2
|
+
export function buildI18nMessage(callback) {
|
|
16
3
|
return (args) => {
|
|
17
|
-
return
|
|
4
|
+
return t(`validation:${callback(args)}`, {
|
|
18
5
|
...args,
|
|
19
6
|
...args.constraints?.reduce((constraints, value, index) => ({
|
|
20
7
|
...constraints,
|
|
21
8
|
[`constraint${String(index)}`]: value,
|
|
22
9
|
}), {}),
|
|
23
|
-
property:
|
|
10
|
+
property: t(`property:${args.property}`),
|
|
24
11
|
});
|
|
25
12
|
};
|
|
26
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-i18n-message.js","sourceRoot":"","sources":["../../src/utils/build-i18n-message.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build-i18n-message.js","sourceRoot":"","sources":["../../src/utils/build-i18n-message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,iBAAiB,CAAC;AAapC,MAAM,UAAU,gBAAgB,CAC9B,QAA+C;IAE/C,OAAO,CAAC,IAAyB,EAAU,EAAE;QAC3C,OAAO,CAAC,CAAC,cAAc,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE;YACvC,GAAG,IAAI;YACP,GAAG,IAAI,CAAC,WAAW,EAAE,MAAM,CACzB,CAAC,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;gBAC9B,GAAG,WAAW;gBACd,CAAC,aAAa,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,KAAK;aACtC,CAAC,EACF,EAAE,CACH;YACD,QAAQ,EAAE,CAAC,CAAC,YAAY,IAAI,CAAC,QAAQ,EAAE,CAAC;SACzC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./build-i18n-message";
|
|
1
|
+
export * from "./build-i18n-message.js";
|
package/dist/utils/index.js
CHANGED
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
|
|
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
|
-
__exportStar(require("./build-i18n-message"), exports);
|
|
1
|
+
export * from "./build-i18n-message.js";
|
|
18
2
|
//# sourceMappingURL=index.js.map
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nest-boot/validator",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0-beta.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/nest-boot/nest-boot.git",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
},
|
|
15
15
|
"homepage": "",
|
|
16
16
|
"license": "MIT",
|
|
17
|
-
"main": "dist/index.js",
|
|
18
|
-
"types": "dist/index.d.ts",
|
|
17
|
+
"main": "./dist/index.js",
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
19
|
"directories": {
|
|
20
20
|
"lib": "dist"
|
|
21
21
|
},
|
|
@@ -23,38 +23,38 @@
|
|
|
23
23
|
"dist"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"lodash": "^4.17.21",
|
|
26
|
+
"lodash-es": "^4.17.21",
|
|
27
27
|
"moment": "^2.30.1",
|
|
28
28
|
"moment-timezone": "^0.6.0",
|
|
29
29
|
"validator": "^13.15.15"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@nestjs/common": "^
|
|
33
|
-
"@nestjs/core": "^
|
|
34
|
-
"@types/
|
|
35
|
-
"@types/node": "^24.12.4",
|
|
32
|
+
"@nestjs/common": "^12.0.1",
|
|
33
|
+
"@nestjs/core": "^12.0.1",
|
|
34
|
+
"@types/node": "^26.0.0",
|
|
36
35
|
"@types/validator": "^13.15.3",
|
|
36
|
+
"@vitest/coverage-v8": "^4.1.11",
|
|
37
37
|
"class-transformer": "^0.5.1",
|
|
38
38
|
"class-validator": "^0.14.2",
|
|
39
39
|
"eslint": "^9.39.3",
|
|
40
|
-
"jest": "^29.7.0",
|
|
41
40
|
"reflect-metadata": "^0.2.2",
|
|
42
41
|
"rxjs": "^7.8.2",
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"@nest-boot/eslint-config": "^
|
|
47
|
-
"@nest-boot/
|
|
48
|
-
"@nest-boot/
|
|
42
|
+
"typescript": "^6.0.3",
|
|
43
|
+
"vite-tsconfig-paths": "^5.1.4",
|
|
44
|
+
"vitest": "^4.1.11",
|
|
45
|
+
"@nest-boot/eslint-config": "^8.0.0-beta.1",
|
|
46
|
+
"@nest-boot/eslint-plugin": "^8.0.0-beta.1",
|
|
47
|
+
"@nest-boot/i18n": "^8.0.0-beta.1",
|
|
48
|
+
"@nest-boot/tsconfig": "^8.0.0-beta.1"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"@
|
|
52
|
-
"@nestjs/
|
|
53
|
-
"@nestjs/core": "^11.0.0",
|
|
51
|
+
"@nestjs/common": "^12.0.0",
|
|
52
|
+
"@nestjs/core": "^12.0.0",
|
|
54
53
|
"class-transformer": "^0.5.1",
|
|
55
54
|
"class-validator": "^0.13.0",
|
|
56
55
|
"reflect-metadata": "^0.2.2",
|
|
57
|
-
"rxjs": "^7.0.0"
|
|
56
|
+
"rxjs": "^7.0.0",
|
|
57
|
+
"@nest-boot/i18n": "^8.0.0-beta.1"
|
|
58
58
|
},
|
|
59
59
|
"publishConfig": {
|
|
60
60
|
"access": "public"
|
|
@@ -65,14 +65,26 @@
|
|
|
65
65
|
"eslint --fix"
|
|
66
66
|
]
|
|
67
67
|
},
|
|
68
|
-
"
|
|
69
|
-
|
|
68
|
+
"type": "module",
|
|
69
|
+
"engines": {
|
|
70
|
+
"node": ">=26.0.0"
|
|
71
|
+
},
|
|
72
|
+
"exports": {
|
|
73
|
+
".": {
|
|
74
|
+
"types": "./dist/index.d.ts",
|
|
75
|
+
"import": "./dist/index.js"
|
|
76
|
+
},
|
|
77
|
+
"./package.json": "./package.json"
|
|
70
78
|
},
|
|
71
79
|
"scripts": {
|
|
72
80
|
"build": "tsc -p tsconfig.build.json",
|
|
73
81
|
"clean": "rm -rf .nx && rm -rf node_modules && rm -rf dist",
|
|
74
82
|
"dev": "tsc -w -p tsconfig.build.json",
|
|
75
83
|
"lint": "eslint \"{src,test}/**/*.ts\"",
|
|
76
|
-
"lint:fix": "eslint \"{src,test}/**/*.ts\" --fix"
|
|
84
|
+
"lint:fix": "eslint \"{src,test}/**/*.ts\" --fix",
|
|
85
|
+
"test": "vitest run",
|
|
86
|
+
"test:cov": "vitest run --coverage",
|
|
87
|
+
"test:watch": "vitest",
|
|
88
|
+
"test:debug": "vitest --inspect-brk --no-file-parallelism"
|
|
77
89
|
}
|
|
78
90
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|