Skip to content

Commit 499df78

Browse files
committed
Add RFC 9562 mentions. Closes #4872
1 parent a9c120e commit 499df78

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

packages/docs/content/api.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ z.uuidv6();
290290
z.uuidv7();
291291
```
292292

293-
The RFC 4122 UUID spec requires the first two bits of byte 8 to be `10`. Other UUID-like identifiers do not enforce this constraint. To validate any UUID-like identifier:
293+
The RFC 9562/4122 UUID spec requires the first two bits of byte 8 to be `10`. Other UUID-like identifiers do not enforce this constraint. To validate any UUID-like identifier:
294294

295295
```ts
296296
z.guid();

packages/docs/content/v4/changelog.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,10 +322,10 @@ z.email(); // ✅
322322

323323
### stricter `.uuid()`
324324

325-
The `z.uuid()` now validates UUIDs more strictly against the RFC 4122 specification; specifically, the variant bits must be `10` per the spec. For a more permissive "UUID-like" validator, use `z.guid()`.
325+
The `z.uuid()` now validates UUIDs more strictly against the RFC 9562/4122 specification; specifically, the variant bits must be `10` per the spec. For a more permissive "UUID-like" validator, use `z.guid()`.
326326

327327
```ts
328-
z.uuid(); // RFC 4122 compliant UUID
328+
z.uuid(); // RFC 9562/4122 compliant UUID
329329
z.guid(); // any 8-4-4-4-12 hex pattern
330330
```
331331

packages/zod/src/v3/tests/string.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,8 @@ test("uuid", () => {
342342
uuid.parse("9491d710-3185-4e06-bea0-6a2f275345e0");
343343
uuid.parse("d89e7b01-7598-ed11-9d7a-0022489382fd"); // new sequential id
344344
uuid.parse("00000000-0000-0000-0000-000000000000");
345-
uuid.parse("b3ce60f8-e8b9-40f5-1150-172ede56ff74"); // Variant 0 - RFC 4122: Reserved, NCS backward compatibility
346-
uuid.parse("92e76bf9-28b3-4730-cd7f-cb6bc51f8c09"); // Variant 2 - RFC 4122: Reserved, Microsoft Corporation backward compatibility
345+
uuid.parse("b3ce60f8-e8b9-40f5-1150-172ede56ff74"); // Variant 0 - RFC 9562/4122: Reserved, NCS backward compatibility
346+
uuid.parse("92e76bf9-28b3-4730-cd7f-cb6bc51f8c09"); // Variant 2 - RFC 9562/4122: Reserved, Microsoft Corporation backward compatibility
347347
const result = uuid.safeParse("9491d710-3185-4e06-bea0-6a2f275345e0X");
348348
expect(result.success).toEqual(false);
349349
if (!result.success) {

packages/zod/src/v4/classic/tests/string.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -464,8 +464,8 @@ test(`bad uuid`, () => {
464464
"9491d710-3185-0e06-bea0-6a2f275345e0",
465465
"9491d710-3185-5e06-0ea0-6a2f275345e0",
466466
"d89e7b01-7598-ed11-9d7a-0022489382fd", // new sequential id
467-
"b3ce60f8-e8b9-40f5-1150-172ede56ff74", // Variant 0 - RFC 4122: Reserved, NCS backward compatibility
468-
"92e76bf9-28b3-4730-cd7f-cb6bc51f8c09", // Variant 2 - RFC 4122: Reserved, Microsoft Corporation backward compatibility
467+
"b3ce60f8-e8b9-40f5-1150-172ede56ff74", // Variant 0 - RFC 9562/4122: Reserved, NCS backward compatibility
468+
"92e76bf9-28b3-4730-cd7f-cb6bc51f8c09", // Variant 2 - RFC 9562/4122: Reserved, Microsoft Corporation backward compatibility
469469
"invalid uuid",
470470
"9491d710-3185-4e06-bea0-6a2f275345e0X",
471471
"ffffffff-ffff-ffff-ffff-ffffffffffff",
@@ -481,8 +481,8 @@ test("good guid", () => {
481481
for (const goodGuid of [
482482
"9491d710-3185-4e06-bea0-6a2f275345e0",
483483
"d89e7b01-7598-ed11-9d7a-0022489382fd", // new sequential id
484-
"b3ce60f8-e8b9-40f5-1150-172ede56ff74", // Variant 0 - RFC 4122: Reserved, NCS backward compatibility
485-
"92e76bf9-28b3-4730-cd7f-cb6bc51f8c09", // Variant 2 - RFC 4122: Reserved, Microsoft Corporation backward compatibility
484+
"b3ce60f8-e8b9-40f5-1150-172ede56ff74", // Variant 0 - RFC 9562/4122: Reserved, NCS backward compatibility
485+
"92e76bf9-28b3-4730-cd7f-cb6bc51f8c09", // Variant 2 - RFC 9562/4122: Reserved, Microsoft Corporation backward compatibility
486486
"00000000-0000-0000-0000-000000000000",
487487
"ffffffff-ffff-ffff-ffff-ffffffffffff",
488488
]) {

packages/zod/src/v4/core/regexes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const extendedDuration: RegExp =
1616
/** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
1717
export const guid: RegExp = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
1818

19-
/** Returns a regex for validating an RFC 4122 UUID.
19+
/** Returns a regex for validating an RFC 9562/4122 UUID.
2020
*
2121
* @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
2222
export const uuid = (version?: number | undefined): RegExp => {

0 commit comments

Comments
 (0)