Skip to content
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

Branded types will not be distinguishable in runtime #1721

Merged
merged 1 commit into from
May 3, 2024

Conversation

RobinTail
Copy link
Owner

@RobinTail RobinTail commented May 3, 2024

Can not express my disappointment in this regard.

colinhacks/zod#2860 (comment)

@RobinTail RobinTail added the wontfix This will not be worked on label May 3, 2024
@RobinTail RobinTail marked this pull request as ready for review May 3, 2024 02:52
@RobinTail RobinTail merged commit 832ccd4 into master May 3, 2024
11 checks passed
@RobinTail RobinTail deleted the RobinTail-patch-2 branch May 3, 2024 02:53
Copy link

Coverage Status

coverage: 100.0%. remained the same
when pulling 386d471 on RobinTail-patch-2
into 5c45f50 on master.

RobinTail added a commit that referenced this pull request May 9, 2024
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`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant