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

Fix regex in cuid2 validation to be what cuid2 library expects #2961

Merged
merged 1 commit into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix regex in cuid2 validation to be what cuid2 library expects
  • Loading branch information
etareduction committed Nov 13, 2023
commit ea6977707960dd6e326504f725bf9029431a980f
1 change: 0 additions & 1 deletion deno/lib/__tests__/string.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ test("cuid2", () => {
validStrings.forEach((s) => cuid2.parse(s));
const invalidStrings = [
"", // empty string
"1z4a98xxat96iws9zmbrgj3a", // starts with a number
"tz4a98xxat96iws9zMbrgj3a", // include uppercase
"tz4a98xxat96iws-zmbrgj3a", // involve symbols
];
Expand Down
1 change: 0 additions & 1 deletion src/__tests__/string.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ test("cuid2", () => {
validStrings.forEach((s) => cuid2.parse(s));
const invalidStrings = [
"", // empty string
"1z4a98xxat96iws9zmbrgj3a", // starts with a number
"tz4a98xxat96iws9zMbrgj3a", // include uppercase
"tz4a98xxat96iws-zmbrgj3a", // involve symbols
];
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ export interface ZodStringDef extends ZodTypeDef {
}

const cuidRegex = /^c[^\s-]{8,}$/i;
const cuid2Regex = /^[a-z][a-z0-9]*$/;
const cuid2Regex = /^[0-9a-z]+$/;
const ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;
// const uuidRegex =
// /^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i;
Expand Down