Skip to content

Commit c6bc80d

Browse files
mohamed-azdAZDOUD Mohamedcolinhacks
authored
Fix issue #3582 : ULID should be case insensitive (#3593)
* Fix issue #3582 : ULID should be case insensitive * Use i flag --------- Co-authored-by: AZDOUD Mohamed <mazdoud-ext@cogelec.fr> Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
1 parent aab9eac commit c6bc80d

File tree

4 files changed

+6
-2
lines changed

4 files changed

+6
-2
lines changed

deno/lib/__tests__/string.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,8 @@ test("ulid", () => {
331331
if (!result.success) {
332332
expect(result.error.issues[0].message).toEqual("Invalid ulid");
333333
}
334+
const caseInsensitive = ulid.safeParse("01arZ3nDeKTsV4RRffQ69G5FAV")
335+
expect(caseInsensitive.success).toEqual(true)
334336
});
335337

336338
test("regex", () => {

deno/lib/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ export interface ZodStringDef extends ZodTypeDef {
575575

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

src/__tests__/string.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,8 @@ test("ulid", () => {
330330
if (!result.success) {
331331
expect(result.error.issues[0].message).toEqual("Invalid ulid");
332332
}
333+
const caseInsensitive = ulid.safeParse("01arZ3nDeKTsV4RRffQ69G5FAV")
334+
expect(caseInsensitive.success).toEqual(true)
333335
});
334336

335337
test("regex", () => {

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ export interface ZodStringDef extends ZodTypeDef {
575575

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

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy