zod-to-json-schema
zod-to-json-schema copied to clipboard
Would it be possible to retain branded types?
Howdy! I understand that the branding system doesn't really exist at runtime, but there could be value in adding wrappers which enable the JSON ser/de to retain the brands. Something along the line of zodToJsonSchemaBranded('my-brand', z.___.brand())
where zodToJsonSchemaBranded<T extends string>(brand: T, schema: z.ZodBranded<T>)
. I think it could be possible for inner .brand function to infer the string from the wrapper.
Hi! Thanks for opening an issue. I'm hesitant to expanding the API for this. Perhaps use the override feature?
Closing for now! Feel free to reopen if it doesn't work out.
No problem! Thanks for the support!