S SmartDocs
시리즈: nest.js typescript 18 줄 · 업데이트 2026-02-03

create-user.dto.ts

nest.js/examples/backend/src/users/dto/create-user.dto.ts

import { IsString, IsEmail, IsNotEmpty, IsOptional, IsInt, Min, Max } from 'class-validator';

export class CreateUserDto {
  @IsString()
  @IsNotEmpty()
  name: string;

  @IsEmail()
  @IsNotEmpty()
  email: string;

  @IsInt()
  @Min(18)
  @Max(100)
  @IsOptional()
  age?: number;
}

관련 글