WEBBOOK CHAPTER

NestJS 11, 시작부터 런칭까지: 5장. DTO와 ValidationPipe

5장. DTO와 ValidationPipe

class-validator DTO로 문자열, enum, 범위, nested object를 검증한다. global ValidationPipe에 whitelist, forbidNonWhitelisted, transform을 둔다. TypeScript type은 runtime 입력을 막지 못한다.

DTO를 entity와 공유하지 않는다. 외부 계약과 내부 persistence의 변경 주기를 분리한다.