class-validator
"Decorator-based property validation for classes."
Dependencies
Setup typescript
To use class-validator, you need to tweak your tsconfig.json
:
Importing the validator
Generate your types
If you generate your types before writing validation, they will be available to help you define the constraint.
Don't forget 'reflect-metadata'
You need to import reflect-metadata
at the top of your file to use
class-validator.
Validate
To validate, just run the validate command: