From d79e460cad3b3f06f053d213812c07b4a585969f Mon Sep 17 00:00:00 2001 From: Jaehyeon Kim <65964601+Jaehyeon1020@users.noreply.github.com> Date: Sun, 24 Nov 2024 02:19:39 +0000 Subject: [PATCH] fix(be): apply runtime typecheck on create-usertest-submission-dto --- .../submission/class/create-submission.dto.ts | 20 ++++++++++++++++++- .../src/submission/submission.controller.ts | 2 +- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/apps/backend/apps/client/src/submission/class/create-submission.dto.ts b/apps/backend/apps/client/src/submission/class/create-submission.dto.ts index c793f5826c..e4579e2051 100644 --- a/apps/backend/apps/client/src/submission/class/create-submission.dto.ts +++ b/apps/backend/apps/client/src/submission/class/create-submission.dto.ts @@ -1,8 +1,10 @@ import { Language } from '@prisma/client' import { Type } from 'class-transformer' import { + IsArray, IsBoolean, IsEnum, + IsInt, IsNotEmpty, IsNumber, IsString, @@ -39,6 +41,22 @@ export class CreateSubmissionDto { } export class CreateUserTestSubmissionDto extends CreateSubmissionDto { + @IsArray() + @ValidateNested({ each: true }) + @Type(() => UserTestcase) + userTestcases: UserTestcase[] +} + +export class UserTestcase { + @IsInt() + @IsNotEmpty() + id: number; + + @IsString() + @IsNotEmpty() + in: string + + @IsString() @IsNotEmpty() - userTestcases: { id: number; in: string; out: string }[] + out: string } diff --git a/apps/backend/apps/client/src/submission/submission.controller.ts b/apps/backend/apps/client/src/submission/submission.controller.ts index e71b0e74d8..7f2c98b678 100644 --- a/apps/backend/apps/client/src/submission/submission.controller.ts +++ b/apps/backend/apps/client/src/submission/submission.controller.ts @@ -18,7 +18,7 @@ import { } from '@libs/pipe' import { CreateSubmissionDto, - type CreateUserTestSubmissionDto + CreateUserTestSubmissionDto } from './class/create-submission.dto' import { SubmissionService } from './submission.service'