From a77482c21ff95638a4aee0dd56fa4dd00519ddd7 Mon Sep 17 00:00:00 2001 From: Alejandro Peralta Date: Thu, 12 Dec 2024 13:52:39 +0100 Subject: [PATCH] fix: CreateCustomProject validation does not apply the validations as they are done via class-validation in the controller. --- .../custom-projects/custom-projects.controller.ts | 4 +++- shared/contracts/custom-projects.contract.ts | 12 +++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/api/src/modules/custom-projects/custom-projects.controller.ts b/api/src/modules/custom-projects/custom-projects.controller.ts index f2be8736..a00ce809 100644 --- a/api/src/modules/custom-projects/custom-projects.controller.ts +++ b/api/src/modules/custom-projects/custom-projects.controller.ts @@ -72,7 +72,9 @@ export class CustomProjectsController { ); } - @TsRestHandler(customProjectContract.createCustomProject) + @TsRestHandler(customProjectContract.createCustomProject, { + validateRequestBody: false, + }) async create( @Body(new ValidationPipe({ enableDebugMessages: true, transform: true })) dto: CreateCustomProjectDto, diff --git a/shared/contracts/custom-projects.contract.ts b/shared/contracts/custom-projects.contract.ts index 5183e33d..482158cd 100644 --- a/shared/contracts/custom-projects.contract.ts +++ b/shared/contracts/custom-projects.contract.ts @@ -1,12 +1,18 @@ import { initContract } from "@ts-rest/core"; -import { ApiPaginationResponse, ApiResponse } from "@shared/dtos/global/api-response.dto"; +import { + ApiPaginationResponse, + ApiResponse, +} from "@shared/dtos/global/api-response.dto"; import { Country } from "@shared/entities/country.entity"; import { ModelAssumptions } from "@shared/entities/model-assumptions.entity"; import { CustomProject } from "@shared/entities/custom-project.entity"; import { GetDefaultCostInputsSchema } from "@shared/schemas/custom-projects/get-cost-inputs.schema"; import { GetAssumptionsSchema } from "@shared/schemas/assumptions/get-assumptions.schema"; -import { CreateCustomProjectSchema, InputCostsSchema } from "@shared/schemas/custom-projects/create-custom-project.schema"; +import { + CreateCustomProjectSchema, + InputCostsSchema, +} from "@shared/schemas/custom-projects/create-custom-project.schema"; import { z } from "zod"; import { generateEntityQuerySchema } from "@shared/schemas/query-param.schema"; import { ActivityTypesDefaults } from "@shared/dtos/custom-projects/activity-types-defaults"; @@ -87,4 +93,4 @@ export const customProjectContract = contract.router({ }, }); -// TODO: Due to dificulties crafting a deeply nested conditional schema, I will go forward with nestjs custom validation pipe for now \ No newline at end of file +// TODO: Due to dificulties crafting a deeply nested conditional schema, I will go forward with nestjs custom validation pipe for now