-
-
Notifications
You must be signed in to change notification settings - Fork 674
Description
Is your feature request related to a problem? Please describe.
Since my project extensively uses zod I want to be able validate InputType
s and maybe ObjectType
s too using zod.
Describe the solution you'd like
something like this?
@InputType()
class Bar {
@ZodValidate(z.string())
@Field()
field: string;
}
Describe alternatives you've considered
Using built in class-validator
or joiful
as described here => https://typegraphql.com/docs/validation.html#custom-validator
Additional context
joiful
does not seem to be well maintained. class-validator
seems not bad but zod
is already quite popular library with friendly and understandable API having high flexibility and customization. So it might be worth to integrate zod with type-graphql
.
I feel like it is already possible to do it with zod by using Extension decorator => https://typegraphql.com/docs/extensions.html and custom validation function => https://typegraphql.com/docs/validation.html#custom-validator but I did not find examples in docs how to do that.
Basically how to extract extensions data in custom validation function?
If it is possible, I can even maybe contribute to add examples with zod validation if needed and someone can give me direction of where to start and where to look for...
So what would be the best way to integrate zod with typegraphql?