#Zod for validation
1 messages · Page 1 of 1 (latest)
There's a guide on how to do with with Joi in the docs: https://docs.nestjs.com/pipes#object-schema-validation
I reckon with zod, it would be similar
there are few community-made packages that might help you: https://npms.io/search?q=nestjs+zod
looks promising
since c-v is not maintained nest should focus on something else
They already forked the c-v and c-t repos. But not being maintained does not mean not working. But swithching everything to work with the new javascript decorators will be a lot of fun.
Here's also a relevant note by Jay: #1074384699587313705 message
do you know any other popular validation lib that have a decorator-based API?
nop, but zod seems a fine alt i think
I think we should have a decorator-based one, due to how the fw was designed
it has certain problems though...i ve shoot in the foot multiple time
can we have zod decorators
the ones I know only have community-made integrations with typescript decorators, which means that we can't use them into the core
hmm this is a serious question
i like zod a lot, can do really complex validations out of the box
then use zod
Nestjs won't force you to use c-v c-t
I believe that until we have a "native" support for TS decorators on zod or any other popular validation lib out there, the core will stick with c-v
Although I don't use class-validator (I've made my own validation pipe using Joi), I don't see any reason to introduce yet another lib with the same role as c-v c-t into the core
We could probably replace it in the future tho
whats your approach with joi
tbh, the API isn't that good because I'm just using Joi (which doesn't have a decorator API)
I've made a decorator to attach the Joi schema object to some class
And then my pipe will recover that schema to perform the validation (as the docs suggests)
I'd try this one: #community-packages message
this looks better btw
you get swagger docs also
but problem comes when we use graphql 😄
What kind of problems ? I am curious
generating graphql schema from zod
currently cli supports parsing DTOs with ts comments to generate schema
but with zod it will be different
i dont like zod
I love Zod, it's making my life so much easier. You can express much more complex APIs easily
Do remember to use strictNullChecks and strict in generall btw
@chrome basalt How about typia ever used that?
never used that, looks interesting
can it do things like min().max()