Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(be): apply runtime typecheck on create-usertest-submission-dto #2238

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Jaehyeon1020
Copy link
Member

Description

closes TAS-1080

CreateUserTestSubmissionDto에 잘못된 속성 입력(in을 input으로 넣는다던지)에 대한 예외가 발생하지 않는 문제를 해결합니다.

Additional context

  • 원인 - 해결방법

    • 일단 아래와 같이 배열 안에 들어가는 객체에 대한 검사가 되지 않고 있었습니다.
    export class CreateSubmissionDto {
      @ValidateNested({ each: true })
      @Type(() => Snippet)
      code: Snippet[]
    
      @IsEnum(Language)
      @IsNotEmpty()
      language: Language
    }
    
    export class CreateUserTestSubmissionDto extends CreateSubmissionDto {
      @IsNotEmpty()
      userTestcases: { id: number; in: string; out: string }[]
    }
    • 그래서 아래와 같이 고쳤는데, 그래도 객체 내의 속성들에 대한 검사가 작동하지 않았습니다.
    export class CreateSubmissionDto {
      @ValidateNested({ each: true })
      @Type(() => Snippet)
      code: Snippet[]
    
      @IsEnum(Language)
      @IsNotEmpty()
      language: Language
    }
    
    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()
      out: string
    }
    • 원인은 CreateUserTestSubmissionDto를 import할 때 type으로 가져왔기 때문이었습니다 …

Before submitting the PR, please make sure you do the following

@coolify-skkuding
Copy link

coolify-skkuding bot commented Nov 24, 2024

The preview deployment is ready. 🟢

Open Preview | Open Build Logs

Last updated at: 2024-11-24 02:29:39 CET

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant