Skip to content

Commit

Permalink
Fix regex in cuid2 validation to be what cuid2 library expects (#2961)
Browse files Browse the repository at this point in the history
  • Loading branch information
etareduction committed Apr 16, 2024
1 parent b2ed20c commit 907e5f2
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 3 deletions.
1 change: 0 additions & 1 deletion deno/lib/__tests__/string.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,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 @@ -275,7 +275,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 @@ -572,7 +572,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

0 comments on commit 907e5f2

Please sign in to comment.