zod 4.1.0-canary.20250711T052917 → 4.1.0-canary.20250711T201420

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zod",
3
- "version": "4.1.0-canary.20250711T052917",
3
+ "version": "4.1.0-canary.20250711T201420",
4
4
  "type": "module",
5
5
  "author": "Colin McDonnell <zod@colinhacks.com>",
6
6
  "description": "TypeScript-first schema declaration and validation library with static type inference",
@@ -342,8 +342,8 @@ test("uuid", () => {
342
342
  uuid.parse("9491d710-3185-4e06-bea0-6a2f275345e0");
343
343
  uuid.parse("d89e7b01-7598-ed11-9d7a-0022489382fd"); // new sequential id
344
344
  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
347
347
  const result = uuid.safeParse("9491d710-3185-4e06-bea0-6a2f275345e0X");
348
348
  expect(result.success).toEqual(false);
349
349
  if (!result.success) {
@@ -1224,6 +1224,7 @@ export interface ZodDiscriminatedUnion<Options extends readonly core.SomeType[]
1224
1224
  extends ZodUnion<Options>,
1225
1225
  core.$ZodDiscriminatedUnion<Options> {
1226
1226
  _zod: core.$ZodDiscriminatedUnionInternals<Options>;
1227
+ def: core.$ZodDiscriminatedUnionDef<Options>;
1227
1228
  }
1228
1229
  export const ZodDiscriminatedUnion: core.$constructor<ZodDiscriminatedUnion> = /*@__PURE__*/ core.$constructor(
1229
1230
  "ZodDiscriminatedUnion",
@@ -646,3 +646,15 @@ test("pipes", () => {
646
646
  v: 2,
647
647
  });
648
648
  });
649
+
650
+ test("def", () => {
651
+ const schema = z.discriminatedUnion(
652
+ "type",
653
+ [z.object({ type: z.literal("play") }), z.object({ type: z.literal("pause") })],
654
+ { unionFallback: true }
655
+ );
656
+
657
+ expect(schema.def).toBeDefined();
658
+ expect(schema.def.discriminator).toEqual("type");
659
+ expect(schema.def.unionFallback).toEqual(true);
660
+ });
@@ -464,8 +464,8 @@ test(`bad uuid`, () => {
464
464
  "9491d710-3185-0e06-bea0-6a2f275345e0",
465
465
  "9491d710-3185-5e06-0ea0-6a2f275345e0",
466
466
  "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
469
469
  "invalid uuid",
470
470
  "9491d710-3185-4e06-bea0-6a2f275345e0X",
471
471
  "ffffffff-ffff-ffff-ffff-ffffffffffff",
@@ -481,8 +481,8 @@ test("good guid", () => {
481
481
  for (const goodGuid of [
482
482
  "9491d710-3185-4e06-bea0-6a2f275345e0",
483
483
  "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
486
486
  "00000000-0000-0000-0000-000000000000",
487
487
  "ffffffff-ffff-ffff-ffff-ffffffffffff",
488
488
  ]) {
@@ -16,7 +16,7 @@ export const extendedDuration: RegExp =
16
16
  /** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
17
17
  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})$/;
18
18
 
19
- /** Returns a regex for validating an RFC 4122 UUID.
19
+ /** Returns a regex for validating an RFC 9562/4122 UUID.
20
20
  *
21
21
  * @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
22
22
  export const uuid = (version?: number | undefined): RegExp => {
@@ -446,6 +446,7 @@ export declare const ZodUnion: core.$constructor<ZodUnion>;
446
446
  export declare function union<const T extends readonly core.SomeType[]>(options: T, params?: string | core.$ZodUnionParams): ZodUnion<T>;
447
447
  export interface ZodDiscriminatedUnion<Options extends readonly core.SomeType[] = readonly core.$ZodType[]> extends ZodUnion<Options>, core.$ZodDiscriminatedUnion<Options> {
448
448
  _zod: core.$ZodDiscriminatedUnionInternals<Options>;
449
+ def: core.$ZodDiscriminatedUnionDef<Options>;
449
450
  }
450
451
  export declare const ZodDiscriminatedUnion: core.$constructor<ZodDiscriminatedUnion>;
451
452
  export declare function discriminatedUnion<Types extends readonly [core.$ZodTypeDiscriminable, ...core.$ZodTypeDiscriminable[]]>(discriminator: string, options: Types, params?: string | core.$ZodDiscriminatedUnionParams): ZodDiscriminatedUnion<Types>;
@@ -446,6 +446,7 @@ export declare const ZodUnion: core.$constructor<ZodUnion>;
446
446
  export declare function union<const T extends readonly core.SomeType[]>(options: T, params?: string | core.$ZodUnionParams): ZodUnion<T>;
447
447
  export interface ZodDiscriminatedUnion<Options extends readonly core.SomeType[] = readonly core.$ZodType[]> extends ZodUnion<Options>, core.$ZodDiscriminatedUnion<Options> {
448
448
  _zod: core.$ZodDiscriminatedUnionInternals<Options>;
449
+ def: core.$ZodDiscriminatedUnionDef<Options>;
449
450
  }
450
451
  export declare const ZodDiscriminatedUnion: core.$constructor<ZodDiscriminatedUnion>;
451
452
  export declare function discriminatedUnion<Types extends readonly [core.$ZodTypeDiscriminable, ...core.$ZodTypeDiscriminable[]]>(discriminator: string, options: Types, params?: string | core.$ZodDiscriminatedUnionParams): ZodDiscriminatedUnion<Types>;
@@ -16,7 +16,7 @@ exports.duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\
16
16
  exports.extendedDuration = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
17
17
  /** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
18
18
  exports.guid = /^([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})$/;
19
- /** Returns a regex for validating an RFC 4122 UUID.
19
+ /** Returns a regex for validating an RFC 9562/4122 UUID.
20
20
  *
21
21
  * @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
22
22
  const uuid = (version) => {
@@ -10,7 +10,7 @@ export declare const duration: RegExp;
10
10
  export declare const extendedDuration: RegExp;
11
11
  /** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
12
12
  export declare const guid: RegExp;
13
- /** Returns a regex for validating an RFC 4122 UUID.
13
+ /** Returns a regex for validating an RFC 9562/4122 UUID.
14
14
  *
15
15
  * @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
16
16
  export declare const uuid: (version?: number | undefined) => RegExp;
@@ -10,7 +10,7 @@ export declare const duration: RegExp;
10
10
  export declare const extendedDuration: RegExp;
11
11
  /** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
12
12
  export declare const guid: RegExp;
13
- /** Returns a regex for validating an RFC 4122 UUID.
13
+ /** Returns a regex for validating an RFC 9562/4122 UUID.
14
14
  *
15
15
  * @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
16
16
  export declare const uuid: (version?: number | undefined) => RegExp;
@@ -10,7 +10,7 @@ export const duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=
10
10
  export const extendedDuration = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
11
11
  /** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
12
12
  export const guid = /^([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})$/;
13
- /** Returns a regex for validating an RFC 4122 UUID.
13
+ /** Returns a regex for validating an RFC 9562/4122 UUID.
14
14
  *
15
15
  * @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
16
16
  export const uuid = (version) => {