framework-do-dede 5.5.0 → 5.5.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.
|
@@ -44,7 +44,7 @@ export default class ControllerHandler {
|
|
|
44
44
|
validatorLike = validator;
|
|
45
45
|
}
|
|
46
46
|
if (typeof validatorLike === 'function') {
|
|
47
|
-
await validateWithClassValidator(validatorLike, request.data, options);
|
|
47
|
+
request.data = await validateWithClassValidator(validatorLike, request.data, options);
|
|
48
48
|
}
|
|
49
49
|
else if (typeof validatorLike.validate === 'function') {
|
|
50
50
|
await validatorLike.validate(request.data);
|
|
@@ -5,4 +5,4 @@ export type ValidationErrorOptions = {
|
|
|
5
5
|
errorName?: string;
|
|
6
6
|
validatorOptions?: ValidatorOptions;
|
|
7
7
|
};
|
|
8
|
-
export declare function validateWithClassValidator<T extends object>(dtoClass: new () => T, input: T, options?: ValidationErrorOptions): Promise<
|
|
8
|
+
export declare function validateWithClassValidator<T extends object>(dtoClass: new () => T, input: T, options?: ValidationErrorOptions): Promise<T>;
|
|
@@ -9,7 +9,7 @@ export async function validateWithClassValidator(dtoClass, input, options = {})
|
|
|
9
9
|
};
|
|
10
10
|
const errors = await validate(instance, validatorOptions);
|
|
11
11
|
if (errors.length === 0)
|
|
12
|
-
return;
|
|
12
|
+
return instance;
|
|
13
13
|
const details = flattenErrors(errors);
|
|
14
14
|
const statusCode = options.statusCode ?? 400;
|
|
15
15
|
const errorName = options.errorName ?? 'BadRequest';
|