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

feat: strict branding with opt-out #3380

Closed
wants to merge 1 commit into from

Conversation

KATT
Copy link
Contributor

@KATT KATT commented Apr 4, 2024

when branding, it's useful to retain the branding on _input so you have to explicitly pass a branded value when using the schema

this reverts #1492 but with the option of opting out of branded behavior

I can make it a non-breaking change if that's preferred, so it default to non-strict mode

cc @Xetera

Copy link

netlify bot commented Apr 4, 2024

Deploy Preview for guileless-rolypoly-866f8a ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit ba19906
🔍 Latest deploy log https://app.netlify.com/sites/guileless-rolypoly-866f8a/deploys/660ece8d2c55b7000779327a
😎 Deploy Preview https://deploy-preview-3380--guileless-rolypoly-866f8a.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

B extends string | number | symbol
> extends ZodType<T["_output"] & BRAND<B>, ZodBrandedDef<T>, T["_input"]> {
B extends string | number | symbol,
S extends boolean
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could be

Suggested change
S extends boolean
S extends boolean = false

if we don't want breaking changes

@@ -466,8 +466,16 @@ export abstract class ZodType<
}) as any;
}

brand<B extends string | number | symbol>(brand?: B): ZodBranded<this, B>;
brand<B extends string | number | symbol>(): ZodBranded<this, B> {
brand<B extends string | number | symbol, S extends boolean = true>(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non-breaking:

Suggested change
brand<B extends string | number | symbol, S extends boolean = true>(
brand<B extends string | number | symbol, S extends boolean = false>(

): ZodBranded<this, B, S>;
brand<
B extends string | number | symbol,
S extends boolean = true
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non-breaking

Suggested change
S extends boolean = true
S extends boolean = false

@KATT KATT closed this Apr 5, 2024
@KATT KATT deleted the feat/input-branded branch April 5, 2024 00:32
@KATT KATT restored the feat/input-branded branch December 17, 2024 10:26
@KATT KATT deleted the feat/input-branded branch December 17, 2024 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant