From e71a9b5144837d28a43ce1f212e1b9a0b1fccb71 Mon Sep 17 00:00:00 2001 From: souravbhowmik1999 Date: Wed, 3 Apr 2024 13:28:17 +0530 Subject: [PATCH] TypeORMError: Provided take value is not a number. Please provide a numeric value --- src/cohort/cohort.controller.ts | 3 +++ src/cohort/dto/cohort-search.dto.ts | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/cohort/cohort.controller.ts b/src/cohort/cohort.controller.ts index 57d229c7..85a35cce 100644 --- a/src/cohort/cohort.controller.ts +++ b/src/cohort/cohort.controller.ts @@ -26,6 +26,8 @@ import { Headers, Delete, UseGuards, + ValidationPipe, + UsePipes, } from "@nestjs/common"; import { CohortSearchDto } from "./dto/cohort-search.dto"; import { Request } from "@nestjs/common"; @@ -133,6 +135,7 @@ export class CohortController { @ApiBody({ type: CohortSearchDto }) @ApiForbiddenResponse({ description: "Forbidden" }) @UseInterceptors(ClassSerializerInterceptor) + @UsePipes(ValidationPipe) @SerializeOptions({ strategy: "excludeAll", }) diff --git a/src/cohort/dto/cohort-search.dto.ts b/src/cohort/dto/cohort-search.dto.ts index b1a76b6f..c265abb4 100644 --- a/src/cohort/dto/cohort-search.dto.ts +++ b/src/cohort/dto/cohort-search.dto.ts @@ -1,10 +1,13 @@ import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger"; +import { IsNumberString } from "class-validator"; + export class CohortSearchDto { @ApiProperty({ type: String, description: "Limit", }) + @IsNumberString() limit: string; @ApiProperty({