Replies: 4 comments 6 replies
-
This is the current TypeProvider template:
Why is the schema even called "input"? Would it not make more sense to call it "schema"?
Or even more configurable:
|
Beta Was this translation helpful? Give feedback.
-
I don't understand why you would add a validation against the output of a validation. Your user would need to specify the input, not the output, at the route level. Overall I'm not opposed to make things more flexible, but it would need not to be breaking. |
Beta Was this translation helpful? Give feedback.
-
#5315 |
Beta Was this translation helpful? Give feedback.
-
Solution 1:
Solution 2:
I prefer solution 1, but this requires creating breaking changes. So I created this PR #5315 to implement solution 2. What do you guys think? Anyone could quickly create PR's to existing type providers to adapt to the new type provider interface. For users using fastify-type-provider-xxx there should be no code changes required. Should I create a PR for solution 1 aswell? |
Beta Was this translation helpful? Give feedback.
-
I am trying to improve the zod type provider to also work with .transform()
This is my current simplified code:
I would like to pass the output from a route (the data that gets serialized) to be typed against the input of a zod schema. The types from querystring, params and body not however since the types are the output of the zod schema.
Zod has an z.input and z.output methods. But currently in fastify we can only create types for both at once.
Would there be a way to create types separatly?
Like for example:
Beta Was this translation helpful? Give feedback.
All reactions