turkerdev / fastify-type-provider-zod

MIT License
303 stars 19 forks source link

[Question] Add passthrough() for parser #55

Closed HannesOberreiter closed 11 months ago

HannesOberreiter commented 11 months ago

Hi,

thanks for the great library. On some routes I would love to allow additional properties. Is there a way to modify the current compiler with a flag to do schema.passthrough().parse();?

https://github.com/colinhacks/zod#passthrough

Thanks in advance!

kibertoad commented 11 months ago

Can't that be done on schema level already?

HannesOberreiter commented 11 months ago

Could not find how. :( The behaviour of strict (if it should fail etc) you can modify at schema level, but not the passthrough.

(Offtopic: big thanks on your work on knex and also helping in objection.js, love the libs!)

kibertoad commented 11 months ago

If you define your body schema as const myschema = z.object({ // definition }).passthrough(), that doesn't suffice?

HannesOberreiter commented 11 months ago

I not even tried to add passthrough on the object, as the documentation on zod shows the parser in the example and I blacked out. But it makes sense as it is a pipe on the object itself ...

Sorry about that, thanks for the help!

kibertoad commented 11 months ago

np!