This is just a general question but I am curious if there is a possibility for NestJS to use a different Validation lirabry since it already could use a different Logging library.
The current library is class-validator.
I am currently building a validator library for personal use for now but am not quite sure how to integrate it into NestJS since it has it own Global config and all the other batteries included for Validation library.
https://docs.nestjs.com/techniques/validation#using-the-built-in-validationpipe
CodePudding user response:
It's absolutely possible to use something other that class-validator
. I personally like @deepkit/types
and am working on providing a ValidationPipe
for it in a package so it can be re-used. But even Nest's docs show using a JoiValidationPipe
(though that one is per route). In short, if the validator is able to use reflection (i.e. it's class based) you can create your DTOs and let your custom validation pipe read the metadata and do the validation, if it's schema based, you'll need a pipe per route (possibly per decorator) to ensure the right schema is being picked up. But yeah, it's definitely possible to use something out, that's one of the wonderful things about Nest.