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: z.string().ulid() - add support for ulids #2049

Merged
merged 4 commits into from Mar 6, 2023

Conversation

chaunceyau
Copy link
Contributor

Overview

Adds support for ulids https://github.com/ulid/spec. Shopify has really popularized these and have a lot of benefits https://news.ycombinator.com/item?id=34294693

@netlify
Copy link

netlify bot commented Feb 17, 2023

Deploy Preview for guileless-rolypoly-866f8a ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 70b95ab
🔍 Latest deploy log https://app.netlify.com/sites/guileless-rolypoly-866f8a/deploys/63fd6bb02873930008ccd97d
😎 Deploy Preview https://deploy-preview-2049--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 settings.

@chaunceyau
Copy link
Contributor Author

cc @colinhacks @hugo-vrijswijk - not sure how to assign reviewers or if it's something only your team does

@chaunceyau chaunceyau changed the title feat: add support for ulids feat: z.string().ulid() - add support for ulids Feb 17, 2023
@@ -903,6 +918,9 @@ export class ZodString extends ZodType<string, ZodStringDef> {
get isCUID2() {
return !!this._def.checks.find((ch) => ch.kind === "cuid2");
}
get isULID() {
return !!this._def.checks.find((ch) => ch.kind === "cuid2");
Copy link

Choose a reason for hiding this comment

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

probably a copy-paste mistake

Suggested change
return !!this._def.checks.find((ch) => ch.kind === "cuid2");
return !!this._def.checks.find((ch) => ch.kind === "ulid");

Choose a reason for hiding this comment

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

good catch, addressed!

src/types.ts Outdated
@@ -903,6 +918,9 @@ export class ZodString extends ZodType<string, ZodStringDef> {
get isCUID2() {
return !!this._def.checks.find((ch) => ch.kind === "cuid2");
}
get isULID() {
return !!this._def.checks.find((ch) => ch.kind === "cuid2");
Copy link

Choose a reason for hiding this comment

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

Same here

Suggested change
return !!this._def.checks.find((ch) => ch.kind === "cuid2");
return !!this._def.checks.find((ch) => ch.kind === "ulid");

Choose a reason for hiding this comment

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

good catch, addressed!

@colinhacks colinhacks merged commit 64883e4 into colinhacks:master Mar 6, 2023
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.

None yet

4 participants