auto-class-validator
v1.0.2
Published
Automatic class-validator integration via typescript transformers, use it with @nestjs/swagger for better experience
Downloads
25
Maintainers
Readme
WORK IN PROGRESS (UNSTABLE)
Automatic validation NestJS class-validator
Installation:
npm install auto-class-validator
Usage
Set up plugin inside nest-cli.json:
{
"$schema": "https://json.schemastore.org/nest-cli",
"collection": "@nestjs/schematics",
"sourceRoot": "src",
"compilerOptions": {
"deleteOutDir": true,
"plugins": [ "auto-class-validator"]
}
}
From this point for any .dto file additional class-validator metadata will be generated:
test.dto
class TestDto {
fieldStr: string;
fieldBool: boolean;
...
}
For each field of the class inside .dto file as in example above, class-validator decorators would be automatically applied.
Support
- Primitives (number, boolean, string)
- Arrays of primitives
- Optional fields