string to number in dto (1) 썸네일형 리스트형 dto에서 type 변환 적용하기 http로 넘어오는 값들은 모두 string로 넘어오기 때문에 body값에 매핑 되어있는 dto중 number 값이 있다면 validate error 가 발생할 수 있다. class-transformer 모듈의 type를 사용하면 controller 단에서 다른 처리를 해주지 않고 dto단에서 타입을 변환시킬 수 있다. import { Type } from 'class-transformer'; export class User { @IsNumber() @Type(() => Number) readonly age: number; } 🎈 https://github.com/nestjs/nest/issues/1331 이전 1 다음