@heliosjs/middlewares 7.0.6 → 7.0.7
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.
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.validate = validate;
|
|
4
|
-
const class_transformer_1 = require("class-transformer");
|
|
5
4
|
const class_validator_1 = require("class-validator");
|
|
6
5
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7
6
|
async function validate(dtoClass, data) {
|
|
@@ -12,11 +11,8 @@ async function validate(dtoClass, data) {
|
|
|
12
11
|
return dtoClass.from(data);
|
|
13
12
|
}
|
|
14
13
|
if (typeof dtoClass === 'function') {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
throw { status: 400, message: 'Validation failed', validationError: 'Empty value' };
|
|
18
|
-
}
|
|
19
|
-
const errors = await (0, class_validator_1.validate)(instance);
|
|
14
|
+
const dto = new dtoClass(data);
|
|
15
|
+
const errors = await (0, class_validator_1.validate)(dto);
|
|
20
16
|
if (errors.length > 0) {
|
|
21
17
|
const validationError = formatValidationErrors(errors);
|
|
22
18
|
throw { status: 400, message: 'Validation failed', validationError };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../src/utils/shared/validate.ts"],"names":[],"mappings":";;AAIA,
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../src/utils/shared/validate.ts"],"names":[],"mappings":";;AAIA,4BAsBC;AAzBD,qDAAwE;AAExE,8DAA8D;AACvD,KAAK,UAAU,QAAQ,CAAC,QAAa,EAAE,IAAa;IACzD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,OAAO,QAAQ,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QACxC,OAAO,QAAQ,CAAC,IAAI,C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
"types": "dist/index.d.ts",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"reflect-metadata": "^0.2.2"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"@heliosjs/core": "^2.4.
|
|
33
|
+
"@heliosjs/core": "^2.4.7",
|
|
34
34
|
"typescript": ">=4.0.0",
|
|
35
35
|
"reflect-metadata": "^0.2.2",
|
|
36
36
|
"@types/node": "^25.5.0"
|