diff --git a/backend/src/main.ts b/backend/src/main.ts index 148c29d..d2a4d7a 100644 --- a/backend/src/main.ts +++ b/backend/src/main.ts @@ -13,7 +13,16 @@ async function bootstrap() { allowedHeaders: 'X-Requested-With, X-HTTP-Method-Override, Content-Type, Accept, Observe', }); - app.useGlobalPipes(new ValidationPipe({ transform: true })); + app.useGlobalPipes(new ValidationPipe({ + transform: true, + exceptionFactory: (errors) => { + const result = errors.map((error) => ({ + property: error.property, + message: error.constraints[Object.keys(error.constraints)[0]], + })); + return new UnprocessableEntityException(result); + }, + })); await app.listen(process.env.PORT ?? 3000); } bootstrap();