class-validator is a TypeScript decorator-based validation library used by NestJS’s built-in ValidationPipe. It allows DTO properties to be annotated with validation rules:

import { IsString, IsInt } from 'class-validator';
 
export class CreateCatDto {
  @IsString() name: string;
  @IsInt() age: number;
  @IsString() breed: string;
}

It works in tandem with class-transformer — the pipe first restores type information via plainToInstance(), then validate() checks the decorators. Supports both synchronous and asynchronous validations.