Lesson 36 of 56
TypescriptValidation with `class-validator` & Decorators
20 minutes
Course progress64%
Install
npm i class-validator class-transformer reflect-metadata
npm i -D @types/class-validator
Add import 'reflect-metadata'; at the entry point.
DTO with decorators
import { IsInt, IsString, Length, validate } from ;
{
()
(, )
name!: ;
()
age!: ;
}
() {
dto = .( (), input);
errors = (dto);
(errors.) ();
dto;
}