Custom validation Libraries without using raw requests #1702
Replies: 2 comments
-
Thanks for the suggestion. |
Beta Was this translation helpful? Give feedback.
-
I get that its more performant, and i agree with that but its also very limiting, what about the situation where you have queryparam and body named the same? there is a bunch of other problems that i can see with that approach which zod or other libraries of that type are solving with their extensive toolbox. maybe adding possibility to use schema input output as parameter to api.raw would solve those issues |
Beta Was this translation helpful? Give feedback.
-
HI! First of all thank you for creating and opensourcing this amazing library, I'm new to microservices and was looking backend framework simmilar to this for quite a long time.
The only problem I'm struggling with is the validation setup based on interfaces:
zod/drizzle infer types aren't working,
directly returning
Promise<User>
is not working, first we need to wrap it in someResult<T> { result:T }
which in my opinion can clutter responseUnions dont work
Promise<User|Error>
resulting in interface with optional fields even thought they will be not presentall of this result in specificaly asserting all responses usually with:
Looking at that i would like to propose additional api parameter called schema
that can work with for example zod:
the body, header, response types can be directly infered from zod without manually asserting them in the api handler
I think this would allow us to compose our validations in a much cleaner way and also integrate with other libraries like
drizzle-zod giving us more options to customize response details
I uderstand that it would require a lot of code changes so im not expecting it to happen, just noticed few problems with current approach that i would like to address
Beta Was this translation helpful? Give feedback.
All reactions