Skip to content

Commit

Permalink
Fix issue colinhacks#3582 : ULID should be case insensitive (colinhac…
Browse files Browse the repository at this point in the history
…ks#3593)

* Fix issue colinhacks#3582 : ULID should be case insensitive

* Use i flag

---------

Co-authored-by: AZDOUD Mohamed <[email protected]>
Co-authored-by: Colin McDonnell <[email protected]>
  • Loading branch information
3 people authored Jun 29, 2024
1 parent aab9eac commit c6bc80d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions deno/lib/__tests__/string.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,8 @@ test("ulid", () => {
if (!result.success) {
expect(result.error.issues[0].message).toEqual("Invalid ulid");
}
const caseInsensitive = ulid.safeParse("01arZ3nDeKTsV4RRffQ69G5FAV")
expect(caseInsensitive.success).toEqual(true)
});

test("regex", () => {
Expand Down
2 changes: 1 addition & 1 deletion deno/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ export interface ZodStringDef extends ZodTypeDef {

const cuidRegex = /^c[^\s-]{8,}$/i;
const cuid2Regex = /^[0-9a-z]+$/;
const ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;
const ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
// 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;
const uuidRegex =
Expand Down
2 changes: 2 additions & 0 deletions src/__tests__/string.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,8 @@ test("ulid", () => {
if (!result.success) {
expect(result.error.issues[0].message).toEqual("Invalid ulid");
}
const caseInsensitive = ulid.safeParse("01arZ3nDeKTsV4RRffQ69G5FAV")
expect(caseInsensitive.success).toEqual(true)
});

test("regex", () => {
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ export interface ZodStringDef extends ZodTypeDef {

const cuidRegex = /^c[^\s-]{8,}$/i;
const cuid2Regex = /^[0-9a-z]+$/;
const ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;
const ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
// 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;
const uuidRegex =
Expand Down

0 comments on commit c6bc80d

Please sign in to comment.