zod 4.0.2 → 4.0.4

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/README.md CHANGED
@@ -10,7 +10,7 @@
10
10
  <br/>
11
11
 
12
12
  <p align="center">
13
- <a href="https://github.com/colinhacks/zod/actions?query=branch%3Amaster"><img src="https://github.com/colinhacks/zod/actions/workflows/test.yml/badge.svg?event=push&branch=master" alt="Zod CI status" /></a>
13
+ <a href="https://github.com/colinhacks/zod/actions?query=branch%3Amain"><img src="https://github.com/colinhacks/zod/actions/workflows/test.yml/badge.svg?event=push&branch=main" alt="Zod CI status" /></a>
14
14
  <a href="https://opensource.org/licenses/MIT" rel="nofollow"><img src="https://img.shields.io/github/license/colinhacks/zod" alt="License"></a>
15
15
  <a href="https://www.npmjs.com/package/zod" rel="nofollow"><img src="https://img.shields.io/npm/dw/zod.svg" alt="npm"></a>
16
16
  <a href="https://discord.gg/KaSRdyX2vc" rel="nofollow"><img src="https://img.shields.io/discord/893487829802418277?label=Discord&logo=discord&logoColor=white" alt="discord server"></a>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zod",
3
- "version": "4.0.2",
3
+ "version": "4.0.4",
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",
@@ -63,4 +63,45 @@ export type {
63
63
  ZodType as Schema,
64
64
  };
65
65
 
66
+ /** Included for Zod 3 compatibility */
66
67
  export type ZodRawShape = core.$ZodShape;
68
+
69
+ /** @deprecated Do not use. Only included for zod-to-json-schema compatibility. */
70
+ export enum ZodFirstPartyTypeKind {
71
+ ZodString = "ZodString",
72
+ ZodNumber = "ZodNumber",
73
+ ZodNaN = "ZodNaN",
74
+ ZodBigInt = "ZodBigInt",
75
+ ZodBoolean = "ZodBoolean",
76
+ ZodDate = "ZodDate",
77
+ ZodSymbol = "ZodSymbol",
78
+ ZodUndefined = "ZodUndefined",
79
+ ZodNull = "ZodNull",
80
+ ZodAny = "ZodAny",
81
+ ZodUnknown = "ZodUnknown",
82
+ ZodNever = "ZodNever",
83
+ ZodVoid = "ZodVoid",
84
+ ZodArray = "ZodArray",
85
+ ZodObject = "ZodObject",
86
+ ZodUnion = "ZodUnion",
87
+ ZodDiscriminatedUnion = "ZodDiscriminatedUnion",
88
+ ZodIntersection = "ZodIntersection",
89
+ ZodTuple = "ZodTuple",
90
+ ZodRecord = "ZodRecord",
91
+ ZodMap = "ZodMap",
92
+ ZodSet = "ZodSet",
93
+ ZodFunction = "ZodFunction",
94
+ ZodLazy = "ZodLazy",
95
+ ZodLiteral = "ZodLiteral",
96
+ ZodEnum = "ZodEnum",
97
+ ZodEffects = "ZodEffects",
98
+ ZodNativeEnum = "ZodNativeEnum",
99
+ ZodOptional = "ZodOptional",
100
+ ZodNullable = "ZodNullable",
101
+ ZodDefault = "ZodDefault",
102
+ ZodCatch = "ZodCatch",
103
+ ZodPromise = "ZodPromise",
104
+ ZodBranded = "ZodBranded",
105
+ ZodPipeline = "ZodPipeline",
106
+ ZodReadonly = "ZodReadonly",
107
+ }
@@ -61,7 +61,8 @@ export interface ZodType<
61
61
 
62
62
  // refinements
63
63
  refine(check: (arg: core.output<this>) => unknown | Promise<unknown>, params?: string | core.$ZodCustomParams): this;
64
- /** @deprecated Use `.check()` instead. */
64
+ /** @deprecated Use [`.check()`](https://zod.dev/api?id=check) instead.
65
+ */
65
66
  superRefine(
66
67
  refinement: (arg: core.output<this>, ctx: RefinementCtx<core.output<this>>) => void | Promise<void>
67
68
  ): this;
@@ -1074,17 +1075,7 @@ export interface ZodObject<
1074
1075
  ): ZodObject<util.Extend<Shape, U>, Config>;
1075
1076
 
1076
1077
  /**
1077
- * @deprecated Use spread syntax and the `.shape` property to combine two object schemas:
1078
- *
1079
- * ```ts
1080
- * const A = z.object({ a: z.string() });
1081
- * const B = z.object({ b: z.number() });
1082
- *
1083
- * const C = z.object({
1084
- * ...A.shape,
1085
- * ...B.shape
1086
- * });
1087
- * ```
1078
+ * @deprecated Use [`A.extend(B.shape)`](https://zod.dev/api?id=extend) instead.
1088
1079
  */
1089
1080
  merge<U extends ZodObject>(other: U): ZodObject<util.Extend<Shape, U["shape"]>, U["_zod"]["config"]>;
1090
1081
 
@@ -1,5 +1,5 @@
1
1
  export const version = {
2
2
  major: 4,
3
3
  minor: 0,
4
- patch: 2 as number,
4
+ patch: 4 as number,
5
5
  } as const;
@@ -24,7 +24,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  return result;
25
25
  };
26
26
  Object.defineProperty(exports, "__esModule", { value: true });
27
- exports.config = exports.$brand = exports.ZodIssueCode = void 0;
27
+ exports.ZodFirstPartyTypeKind = exports.config = exports.$brand = exports.ZodIssueCode = void 0;
28
28
  exports.setErrorMap = setErrorMap;
29
29
  exports.getErrorMap = getErrorMap;
30
30
  const core = __importStar(require("../core/index.cjs"));
@@ -55,3 +55,43 @@ function setErrorMap(map) {
55
55
  function getErrorMap() {
56
56
  return core.config().customError;
57
57
  }
58
+ /** @deprecated Do not use. Only included for zod-to-json-schema compatibility. */
59
+ var ZodFirstPartyTypeKind;
60
+ (function (ZodFirstPartyTypeKind) {
61
+ ZodFirstPartyTypeKind["ZodString"] = "ZodString";
62
+ ZodFirstPartyTypeKind["ZodNumber"] = "ZodNumber";
63
+ ZodFirstPartyTypeKind["ZodNaN"] = "ZodNaN";
64
+ ZodFirstPartyTypeKind["ZodBigInt"] = "ZodBigInt";
65
+ ZodFirstPartyTypeKind["ZodBoolean"] = "ZodBoolean";
66
+ ZodFirstPartyTypeKind["ZodDate"] = "ZodDate";
67
+ ZodFirstPartyTypeKind["ZodSymbol"] = "ZodSymbol";
68
+ ZodFirstPartyTypeKind["ZodUndefined"] = "ZodUndefined";
69
+ ZodFirstPartyTypeKind["ZodNull"] = "ZodNull";
70
+ ZodFirstPartyTypeKind["ZodAny"] = "ZodAny";
71
+ ZodFirstPartyTypeKind["ZodUnknown"] = "ZodUnknown";
72
+ ZodFirstPartyTypeKind["ZodNever"] = "ZodNever";
73
+ ZodFirstPartyTypeKind["ZodVoid"] = "ZodVoid";
74
+ ZodFirstPartyTypeKind["ZodArray"] = "ZodArray";
75
+ ZodFirstPartyTypeKind["ZodObject"] = "ZodObject";
76
+ ZodFirstPartyTypeKind["ZodUnion"] = "ZodUnion";
77
+ ZodFirstPartyTypeKind["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
78
+ ZodFirstPartyTypeKind["ZodIntersection"] = "ZodIntersection";
79
+ ZodFirstPartyTypeKind["ZodTuple"] = "ZodTuple";
80
+ ZodFirstPartyTypeKind["ZodRecord"] = "ZodRecord";
81
+ ZodFirstPartyTypeKind["ZodMap"] = "ZodMap";
82
+ ZodFirstPartyTypeKind["ZodSet"] = "ZodSet";
83
+ ZodFirstPartyTypeKind["ZodFunction"] = "ZodFunction";
84
+ ZodFirstPartyTypeKind["ZodLazy"] = "ZodLazy";
85
+ ZodFirstPartyTypeKind["ZodLiteral"] = "ZodLiteral";
86
+ ZodFirstPartyTypeKind["ZodEnum"] = "ZodEnum";
87
+ ZodFirstPartyTypeKind["ZodEffects"] = "ZodEffects";
88
+ ZodFirstPartyTypeKind["ZodNativeEnum"] = "ZodNativeEnum";
89
+ ZodFirstPartyTypeKind["ZodOptional"] = "ZodOptional";
90
+ ZodFirstPartyTypeKind["ZodNullable"] = "ZodNullable";
91
+ ZodFirstPartyTypeKind["ZodDefault"] = "ZodDefault";
92
+ ZodFirstPartyTypeKind["ZodCatch"] = "ZodCatch";
93
+ ZodFirstPartyTypeKind["ZodPromise"] = "ZodPromise";
94
+ ZodFirstPartyTypeKind["ZodBranded"] = "ZodBranded";
95
+ ZodFirstPartyTypeKind["ZodPipeline"] = "ZodPipeline";
96
+ ZodFirstPartyTypeKind["ZodReadonly"] = "ZodReadonly";
97
+ })(ZodFirstPartyTypeKind || (exports.ZodFirstPartyTypeKind = ZodFirstPartyTypeKind = {}));
@@ -43,4 +43,44 @@ ZodType as ZodTypeAny,
43
43
  ZodType as ZodSchema,
44
44
  /** @deprecated Use `z.ZodType` */
45
45
  ZodType as Schema, };
46
+ /** Included for Zod 3 compatibility */
46
47
  export type ZodRawShape = core.$ZodShape;
48
+ /** @deprecated Do not use. Only included for zod-to-json-schema compatibility. */
49
+ export declare enum ZodFirstPartyTypeKind {
50
+ ZodString = "ZodString",
51
+ ZodNumber = "ZodNumber",
52
+ ZodNaN = "ZodNaN",
53
+ ZodBigInt = "ZodBigInt",
54
+ ZodBoolean = "ZodBoolean",
55
+ ZodDate = "ZodDate",
56
+ ZodSymbol = "ZodSymbol",
57
+ ZodUndefined = "ZodUndefined",
58
+ ZodNull = "ZodNull",
59
+ ZodAny = "ZodAny",
60
+ ZodUnknown = "ZodUnknown",
61
+ ZodNever = "ZodNever",
62
+ ZodVoid = "ZodVoid",
63
+ ZodArray = "ZodArray",
64
+ ZodObject = "ZodObject",
65
+ ZodUnion = "ZodUnion",
66
+ ZodDiscriminatedUnion = "ZodDiscriminatedUnion",
67
+ ZodIntersection = "ZodIntersection",
68
+ ZodTuple = "ZodTuple",
69
+ ZodRecord = "ZodRecord",
70
+ ZodMap = "ZodMap",
71
+ ZodSet = "ZodSet",
72
+ ZodFunction = "ZodFunction",
73
+ ZodLazy = "ZodLazy",
74
+ ZodLiteral = "ZodLiteral",
75
+ ZodEnum = "ZodEnum",
76
+ ZodEffects = "ZodEffects",
77
+ ZodNativeEnum = "ZodNativeEnum",
78
+ ZodOptional = "ZodOptional",
79
+ ZodNullable = "ZodNullable",
80
+ ZodDefault = "ZodDefault",
81
+ ZodCatch = "ZodCatch",
82
+ ZodPromise = "ZodPromise",
83
+ ZodBranded = "ZodBranded",
84
+ ZodPipeline = "ZodPipeline",
85
+ ZodReadonly = "ZodReadonly"
86
+ }
@@ -43,4 +43,44 @@ ZodType as ZodTypeAny,
43
43
  ZodType as ZodSchema,
44
44
  /** @deprecated Use `z.ZodType` */
45
45
  ZodType as Schema, };
46
+ /** Included for Zod 3 compatibility */
46
47
  export type ZodRawShape = core.$ZodShape;
48
+ /** @deprecated Do not use. Only included for zod-to-json-schema compatibility. */
49
+ export declare enum ZodFirstPartyTypeKind {
50
+ ZodString = "ZodString",
51
+ ZodNumber = "ZodNumber",
52
+ ZodNaN = "ZodNaN",
53
+ ZodBigInt = "ZodBigInt",
54
+ ZodBoolean = "ZodBoolean",
55
+ ZodDate = "ZodDate",
56
+ ZodSymbol = "ZodSymbol",
57
+ ZodUndefined = "ZodUndefined",
58
+ ZodNull = "ZodNull",
59
+ ZodAny = "ZodAny",
60
+ ZodUnknown = "ZodUnknown",
61
+ ZodNever = "ZodNever",
62
+ ZodVoid = "ZodVoid",
63
+ ZodArray = "ZodArray",
64
+ ZodObject = "ZodObject",
65
+ ZodUnion = "ZodUnion",
66
+ ZodDiscriminatedUnion = "ZodDiscriminatedUnion",
67
+ ZodIntersection = "ZodIntersection",
68
+ ZodTuple = "ZodTuple",
69
+ ZodRecord = "ZodRecord",
70
+ ZodMap = "ZodMap",
71
+ ZodSet = "ZodSet",
72
+ ZodFunction = "ZodFunction",
73
+ ZodLazy = "ZodLazy",
74
+ ZodLiteral = "ZodLiteral",
75
+ ZodEnum = "ZodEnum",
76
+ ZodEffects = "ZodEffects",
77
+ ZodNativeEnum = "ZodNativeEnum",
78
+ ZodOptional = "ZodOptional",
79
+ ZodNullable = "ZodNullable",
80
+ ZodDefault = "ZodDefault",
81
+ ZodCatch = "ZodCatch",
82
+ ZodPromise = "ZodPromise",
83
+ ZodBranded = "ZodBranded",
84
+ ZodPipeline = "ZodPipeline",
85
+ ZodReadonly = "ZodReadonly"
86
+ }
@@ -25,3 +25,43 @@ export function setErrorMap(map) {
25
25
  export function getErrorMap() {
26
26
  return core.config().customError;
27
27
  }
28
+ /** @deprecated Do not use. Only included for zod-to-json-schema compatibility. */
29
+ export var ZodFirstPartyTypeKind;
30
+ (function (ZodFirstPartyTypeKind) {
31
+ ZodFirstPartyTypeKind["ZodString"] = "ZodString";
32
+ ZodFirstPartyTypeKind["ZodNumber"] = "ZodNumber";
33
+ ZodFirstPartyTypeKind["ZodNaN"] = "ZodNaN";
34
+ ZodFirstPartyTypeKind["ZodBigInt"] = "ZodBigInt";
35
+ ZodFirstPartyTypeKind["ZodBoolean"] = "ZodBoolean";
36
+ ZodFirstPartyTypeKind["ZodDate"] = "ZodDate";
37
+ ZodFirstPartyTypeKind["ZodSymbol"] = "ZodSymbol";
38
+ ZodFirstPartyTypeKind["ZodUndefined"] = "ZodUndefined";
39
+ ZodFirstPartyTypeKind["ZodNull"] = "ZodNull";
40
+ ZodFirstPartyTypeKind["ZodAny"] = "ZodAny";
41
+ ZodFirstPartyTypeKind["ZodUnknown"] = "ZodUnknown";
42
+ ZodFirstPartyTypeKind["ZodNever"] = "ZodNever";
43
+ ZodFirstPartyTypeKind["ZodVoid"] = "ZodVoid";
44
+ ZodFirstPartyTypeKind["ZodArray"] = "ZodArray";
45
+ ZodFirstPartyTypeKind["ZodObject"] = "ZodObject";
46
+ ZodFirstPartyTypeKind["ZodUnion"] = "ZodUnion";
47
+ ZodFirstPartyTypeKind["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
48
+ ZodFirstPartyTypeKind["ZodIntersection"] = "ZodIntersection";
49
+ ZodFirstPartyTypeKind["ZodTuple"] = "ZodTuple";
50
+ ZodFirstPartyTypeKind["ZodRecord"] = "ZodRecord";
51
+ ZodFirstPartyTypeKind["ZodMap"] = "ZodMap";
52
+ ZodFirstPartyTypeKind["ZodSet"] = "ZodSet";
53
+ ZodFirstPartyTypeKind["ZodFunction"] = "ZodFunction";
54
+ ZodFirstPartyTypeKind["ZodLazy"] = "ZodLazy";
55
+ ZodFirstPartyTypeKind["ZodLiteral"] = "ZodLiteral";
56
+ ZodFirstPartyTypeKind["ZodEnum"] = "ZodEnum";
57
+ ZodFirstPartyTypeKind["ZodEffects"] = "ZodEffects";
58
+ ZodFirstPartyTypeKind["ZodNativeEnum"] = "ZodNativeEnum";
59
+ ZodFirstPartyTypeKind["ZodOptional"] = "ZodOptional";
60
+ ZodFirstPartyTypeKind["ZodNullable"] = "ZodNullable";
61
+ ZodFirstPartyTypeKind["ZodDefault"] = "ZodDefault";
62
+ ZodFirstPartyTypeKind["ZodCatch"] = "ZodCatch";
63
+ ZodFirstPartyTypeKind["ZodPromise"] = "ZodPromise";
64
+ ZodFirstPartyTypeKind["ZodBranded"] = "ZodBranded";
65
+ ZodFirstPartyTypeKind["ZodPipeline"] = "ZodPipeline";
66
+ ZodFirstPartyTypeKind["ZodReadonly"] = "ZodReadonly";
67
+ })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
@@ -25,7 +25,8 @@ export interface ZodType<out Output = unknown, out Input = unknown, out Internal
25
25
  safeParseAsync(data: unknown, params?: core.ParseContext<core.$ZodIssue>): Promise<parse.ZodSafeParseResult<core.output<this>>>;
26
26
  spa: (data: unknown, params?: core.ParseContext<core.$ZodIssue>) => Promise<parse.ZodSafeParseResult<core.output<this>>>;
27
27
  refine(check: (arg: core.output<this>) => unknown | Promise<unknown>, params?: string | core.$ZodCustomParams): this;
28
- /** @deprecated Use `.check()` instead. */
28
+ /** @deprecated Use [`.check()`](https://zod.dev/api?id=check) instead.
29
+ */
29
30
  superRefine(refinement: (arg: core.output<this>, ctx: RefinementCtx<core.output<this>>) => void | Promise<void>): this;
30
31
  overwrite(fn: (x: core.output<this>) => core.output<this>): this;
31
32
  optional(): ZodOptional<this>;
@@ -416,17 +417,7 @@ out Shape extends core.$ZodShape = core.$ZodLooseShape, out Config extends core.
416
417
  strip(): ZodObject<Shape, core.$strip>;
417
418
  extend<U extends core.$ZodLooseShape & Partial<Record<keyof Shape, core.SomeType>>>(shape: U): ZodObject<util.Extend<Shape, U>, Config>;
418
419
  /**
419
- * @deprecated Use spread syntax and the `.shape` property to combine two object schemas:
420
- *
421
- * ```ts
422
- * const A = z.object({ a: z.string() });
423
- * const B = z.object({ b: z.number() });
424
- *
425
- * const C = z.object({
426
- * ...A.shape,
427
- * ...B.shape
428
- * });
429
- * ```
420
+ * @deprecated Use [`A.extend(B.shape)`](https://zod.dev/api?id=extend) instead.
430
421
  */
431
422
  merge<U extends ZodObject>(other: U): ZodObject<util.Extend<Shape, U["shape"]>, U["_zod"]["config"]>;
432
423
  pick<M extends util.Mask<keyof Shape>>(mask: M): ZodObject<util.Flatten<Pick<Shape, Extract<keyof Shape, keyof M>>>, Config>;
@@ -25,7 +25,8 @@ export interface ZodType<out Output = unknown, out Input = unknown, out Internal
25
25
  safeParseAsync(data: unknown, params?: core.ParseContext<core.$ZodIssue>): Promise<parse.ZodSafeParseResult<core.output<this>>>;
26
26
  spa: (data: unknown, params?: core.ParseContext<core.$ZodIssue>) => Promise<parse.ZodSafeParseResult<core.output<this>>>;
27
27
  refine(check: (arg: core.output<this>) => unknown | Promise<unknown>, params?: string | core.$ZodCustomParams): this;
28
- /** @deprecated Use `.check()` instead. */
28
+ /** @deprecated Use [`.check()`](https://zod.dev/api?id=check) instead.
29
+ */
29
30
  superRefine(refinement: (arg: core.output<this>, ctx: RefinementCtx<core.output<this>>) => void | Promise<void>): this;
30
31
  overwrite(fn: (x: core.output<this>) => core.output<this>): this;
31
32
  optional(): ZodOptional<this>;
@@ -416,17 +417,7 @@ out Shape extends core.$ZodShape = core.$ZodLooseShape, out Config extends core.
416
417
  strip(): ZodObject<Shape, core.$strip>;
417
418
  extend<U extends core.$ZodLooseShape & Partial<Record<keyof Shape, core.SomeType>>>(shape: U): ZodObject<util.Extend<Shape, U>, Config>;
418
419
  /**
419
- * @deprecated Use spread syntax and the `.shape` property to combine two object schemas:
420
- *
421
- * ```ts
422
- * const A = z.object({ a: z.string() });
423
- * const B = z.object({ b: z.number() });
424
- *
425
- * const C = z.object({
426
- * ...A.shape,
427
- * ...B.shape
428
- * });
429
- * ```
420
+ * @deprecated Use [`A.extend(B.shape)`](https://zod.dev/api?id=extend) instead.
430
421
  */
431
422
  merge<U extends ZodObject>(other: U): ZodObject<util.Extend<Shape, U["shape"]>, U["_zod"]["config"]>;
432
423
  pick<M extends util.Mask<keyof Shape>>(mask: M): ZodObject<util.Flatten<Pick<Shape, Extract<keyof Shape, keyof M>>>, Config>;
@@ -4,5 +4,5 @@ exports.version = void 0;
4
4
  exports.version = {
5
5
  major: 4,
6
6
  minor: 0,
7
- patch: 2,
7
+ patch: 4,
8
8
  };
@@ -1,5 +1,5 @@
1
1
  export const version = {
2
2
  major: 4,
3
3
  minor: 0,
4
- patch: 2,
4
+ patch: 4,
5
5
  };