-
-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Metadata without withMeta()
#1719
Conversation
withMeta
The approach on altering prototypes of The final plugin implementation is here (slightly changed): |
withMeta
withMeta
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
30909f8
to
74407d8
Compare
74407d8
to
fbc32d9
Compare
✅ QA passed |
Due to #1721, colinhacks/zod#2860 (comment), and #1719 I'm exploring the possibility to alter the behaviour of `.brand()` for storing the `brand` property as a way to distinguish the proprietary schemas in runtime. This can replace the `proprietary()` function with a call of `.brand()`. However, so far it turned out to be breaking because `ZodBranded` does not expose the methods of the wrapped schema, such as `.extend()`, which is used in `accept-raw.ts` endpoint for possible route params. —— After a series of serious considerations I realized that exposing brand to consumers of `express-zod-api` could be a beneficial feature. Runtime brand can be accessed via `._def[Symbol.for("express-zod-api")].brand`
According to the Zod author's PR, it's kinda OK to alter Zod's prototypes:
https://github.com/colinhacks/zod/pull/3445/files#diff-d8a41ab20c64f92092513f153b78e7bbf5dc929c92909fad25e03d53c7f15bb7R21-R37
I tried to avoid that when I created
withMeta()
, but since Colin is doing it themselves, this approach could be beneficial for consumers.