zod 3.25.73 → 3.25.75

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": "3.25.73",
3
+ "version": "3.25.75",
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",
@@ -1359,11 +1359,11 @@ export function partialRecord<Key extends core.$ZodRecordKey, Value extends core
1359
1359
  keyType: Key,
1360
1360
  valueType: Value,
1361
1361
  params?: string | core.$ZodRecordParams
1362
- ): ZodRecord<Key, ZodOptional<Value>> {
1362
+ ): ZodRecord<Key & core.$partial, Value> {
1363
1363
  return new ZodRecord({
1364
1364
  type: "record",
1365
1365
  keyType: union([keyType, never()]),
1366
- valueType: optional(valueType),
1366
+ valueType: valueType as any,
1367
1367
  ...util.normalizeParams(params),
1368
1368
  }) as any;
1369
1369
  }
@@ -335,4 +335,8 @@ test("partial record", () => {
335
335
  const schema = z.partialRecord(z.string(), z.string());
336
336
  type schema = z.infer<typeof schema>;
337
337
  expectTypeOf<schema>().toEqualTypeOf<Partial<Record<string, string>>>();
338
+
339
+ const Keys = z.enum(["id", "name", "email"]).or(z.never());
340
+ const Person = z.partialRecord(Keys, z.string());
341
+ expectTypeOf<z.infer<typeof Person>>().toEqualTypeOf<Partial<Record<"id" | "name" | "email", string>>>();
338
342
  });
@@ -28,10 +28,9 @@ describe("toJSONSchema", () => {
28
28
  "type": "null",
29
29
  }
30
30
  `);
31
- expect(z.toJSONSchema(z.undefined())).toMatchInlineSnapshot(`
31
+ expect(z.toJSONSchema(z.undefined(), { unrepresentable: "any" })).toMatchInlineSnapshot(`
32
32
  {
33
33
  "$schema": "https://json-schema.org/draft/2020-12/schema",
34
- "not": {},
35
34
  }
36
35
  `);
37
36
  expect(z.toJSONSchema(z.any())).toMatchInlineSnapshot(`
@@ -232,6 +231,7 @@ describe("toJSONSchema", () => {
232
231
  expect(() => z.toJSONSchema(z.int64())).toThrow("BigInt cannot be represented in JSON Schema");
233
232
  expect(() => z.toJSONSchema(z.symbol())).toThrow("Symbols cannot be represented in JSON Schema");
234
233
  expect(() => z.toJSONSchema(z.void())).toThrow("Void cannot be represented in JSON Schema");
234
+ expect(() => z.toJSONSchema(z.undefined())).toThrow("Undefined cannot be represented in JSON Schema");
235
235
  expect(() => z.toJSONSchema(z.date())).toThrow("Date cannot be represented in JSON Schema");
236
236
  expect(() => z.toJSONSchema(z.map(z.string(), z.number()))).toThrow("Map cannot be represented in JSON Schema");
237
237
  expect(() => z.toJSONSchema(z.set(z.string()))).toThrow("Set cannot be represented in JSON Schema");
@@ -1887,9 +1887,8 @@ test("input type", () => {
1887
1887
  e: z.string().prefault("hello"),
1888
1888
  f: z.string().catch("hello"),
1889
1889
  g: z.never(),
1890
- h: z.undefined(),
1891
- i: z.union([z.string(), z.number().default(2)]),
1892
- j: z.union([z.string(), z.string().optional()]),
1890
+ h: z.union([z.string(), z.number().default(2)]),
1891
+ i: z.union([z.string(), z.string().optional()]),
1893
1892
  });
1894
1893
  expect(z.toJSONSchema(schema, { io: "input" })).toMatchInlineSnapshot(`
1895
1894
  {
@@ -1927,9 +1926,6 @@ test("input type", () => {
1927
1926
  "not": {},
1928
1927
  },
1929
1928
  "h": {
1930
- "not": {},
1931
- },
1932
- "i": {
1933
1929
  "anyOf": [
1934
1930
  {
1935
1931
  "type": "string",
@@ -1940,7 +1936,7 @@ test("input type", () => {
1940
1936
  },
1941
1937
  ],
1942
1938
  },
1943
- "j": {
1939
+ "i": {
1944
1940
  "anyOf": [
1945
1941
  {
1946
1942
  "type": "string",
@@ -1995,9 +1991,6 @@ test("input type", () => {
1995
1991
  "not": {},
1996
1992
  },
1997
1993
  "h": {
1998
- "not": {},
1999
- },
2000
- "i": {
2001
1994
  "anyOf": [
2002
1995
  {
2003
1996
  "type": "string",
@@ -2008,7 +2001,7 @@ test("input type", () => {
2008
2001
  },
2009
2002
  ],
2010
2003
  },
2011
- "j": {
2004
+ "i": {
2012
2005
  "anyOf": [
2013
2006
  {
2014
2007
  "type": "string",
@@ -2026,7 +2019,7 @@ test("input type", () => {
2026
2019
  "e",
2027
2020
  "f",
2028
2021
  "g",
2029
- "i",
2022
+ "h",
2030
2023
  ],
2031
2024
  "type": "object",
2032
2025
  }
@@ -2106,6 +2106,8 @@ export interface $ZodIntersectionInternals<A extends SomeType = $ZodType, B exte
2106
2106
  extends $ZodTypeInternals<core.output<A> & core.output<B>, core.input<A> & core.input<B>> {
2107
2107
  def: $ZodIntersectionDef<A, B>;
2108
2108
  isst: never;
2109
+ optin: A["_zod"]["optin"] | B["_zod"]["optin"];
2110
+ optout: A["_zod"]["optout"] | B["_zod"]["optout"];
2109
2111
  }
2110
2112
 
2111
2113
  export interface $ZodIntersection<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodType {
@@ -2376,38 +2378,53 @@ export interface $ZodRecordDef<Key extends $ZodRecordKey = $ZodRecordKey, Value
2376
2378
  valueType: Value;
2377
2379
  }
2378
2380
 
2381
+ // export type $InferZodRecordOutput<
2382
+ // Key extends $ZodRecordKey = $ZodRecordKey,
2383
+ // Value extends SomeType = $ZodType,
2384
+ // > = undefined extends Key["_zod"]["values"]
2385
+ // ? string extends core.output<Key>
2386
+ // ? Record<core.output<Key>, core.output<Value>>
2387
+ // : number extends core.output<Key>
2388
+ // ? Record<core.output<Key>, core.output<Value>>
2389
+ // : symbol extends core.output<Key>
2390
+ // ? Record<core.output<Key>, core.output<Value>>
2391
+ // : Record<core.output<Key>, core.output<Value>>
2392
+ // : Record<core.output<Key>, core.output<Value>>;
2379
2393
  export type $InferZodRecordOutput<
2380
2394
  Key extends $ZodRecordKey = $ZodRecordKey,
2381
2395
  Value extends SomeType = $ZodType,
2382
- > = undefined extends Key["_zod"]["values"]
2383
- ? string extends core.output<Key>
2384
- ? Record<core.output<Key>, core.output<Value>>
2385
- : number extends core.output<Key>
2386
- ? Record<core.output<Key>, core.output<Value>>
2387
- : symbol extends core.output<Key>
2388
- ? Record<core.output<Key>, core.output<Value>>
2389
- : Record<core.output<Key>, core.output<Value>>
2396
+ > = Key extends $partial
2397
+ ? Partial<Record<core.output<Key>, core.output<Value>>>
2390
2398
  : Record<core.output<Key>, core.output<Value>>;
2391
2399
 
2400
+ // export type $InferZodRecordInput<
2401
+ // Key extends $ZodRecordKey = $ZodRecordKey,
2402
+ // Value extends SomeType = $ZodType,
2403
+ // > = undefined extends Key["_zod"]["values"]
2404
+ // ? string extends core.input<Key>
2405
+ // ? Record<core.input<Key>, core.input<Value>>
2406
+ // : number extends core.input<Key>
2407
+ // ? Record<core.input<Key>, core.input<Value>>
2408
+ // : symbol extends core.input<Key>
2409
+ // ? Record<core.input<Key>, core.input<Value>>
2410
+ // : Record<core.input<Key>, core.input<Value>>
2411
+ // : Record<core.input<Key>, core.input<Value>>;
2392
2412
  export type $InferZodRecordInput<
2393
2413
  Key extends $ZodRecordKey = $ZodRecordKey,
2394
2414
  Value extends SomeType = $ZodType,
2395
- > = undefined extends Key["_zod"]["values"]
2396
- ? string extends core.input<Key>
2397
- ? Record<core.input<Key>, core.input<Value>>
2398
- : number extends core.input<Key>
2399
- ? Record<core.input<Key>, core.input<Value>>
2400
- : symbol extends core.input<Key>
2401
- ? Record<core.input<Key>, core.input<Value>>
2402
- : Record<core.input<Key>, core.input<Value>>
2415
+ > = Key extends $partial
2416
+ ? Partial<Record<core.input<Key>, core.input<Value>>>
2403
2417
  : Record<core.input<Key>, core.input<Value>>;
2404
2418
 
2405
2419
  export interface $ZodRecordInternals<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType>
2406
2420
  extends $ZodTypeInternals<$InferZodRecordOutput<Key, Value>, $InferZodRecordInput<Key, Value>> {
2407
2421
  def: $ZodRecordDef<Key, Value>;
2408
2422
  isst: errors.$ZodIssueInvalidType | errors.$ZodIssueInvalidKey<Record<PropertyKey, unknown>>;
2423
+ optin?: "optional" | undefined;
2424
+ optout?: "optional" | undefined;
2409
2425
  }
2410
2426
 
2427
+ export type $partial = { "~~partial": true };
2411
2428
  export interface $ZodRecord<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType>
2412
2429
  extends $ZodType {
2413
2430
  _zod: $ZodRecordInternals<Key, Value>;
@@ -2538,6 +2555,8 @@ export interface $ZodMapInternals<Key extends SomeType = $ZodType, Value extends
2538
2555
  extends $ZodTypeInternals<Map<core.output<Key>, core.output<Value>>, Map<core.input<Key>, core.input<Value>>> {
2539
2556
  def: $ZodMapDef<Key, Value>;
2540
2557
  isst: errors.$ZodIssueInvalidType | errors.$ZodIssueInvalidKey | errors.$ZodIssueInvalidElement<unknown>;
2558
+ optin?: "optional" | undefined;
2559
+ optout?: "optional" | undefined;
2541
2560
  }
2542
2561
 
2543
2562
  export interface $ZodMap<Key extends SomeType = $ZodType, Value extends SomeType = $ZodType> extends $ZodType {
@@ -2637,6 +2656,8 @@ export interface $ZodSetInternals<T extends SomeType = $ZodType>
2637
2656
  extends $ZodTypeInternals<Set<core.output<T>>, Set<core.input<T>>> {
2638
2657
  def: $ZodSetDef<T>;
2639
2658
  isst: errors.$ZodIssueInvalidType;
2659
+ optin?: "optional" | undefined;
2660
+ optout?: "optional" | undefined;
2640
2661
  }
2641
2662
 
2642
2663
  export interface $ZodSet<T extends SomeType = $ZodType> extends $ZodType {
@@ -3047,6 +3068,7 @@ export interface $ZodDefaultInternals<T extends SomeType = $ZodType>
3047
3068
  extends $ZodTypeInternals<util.NoUndefined<core.output<T>>, core.input<T> | undefined> {
3048
3069
  def: $ZodDefaultDef<T>;
3049
3070
  optin: "optional";
3071
+ optout?: "optional" | undefined; // required
3050
3072
  isst: never;
3051
3073
  values: T["_zod"]["values"];
3052
3074
  }
@@ -3107,6 +3129,7 @@ export interface $ZodPrefaultInternals<T extends SomeType = $ZodType>
3107
3129
  extends $ZodTypeInternals<util.NoUndefined<core.output<T>>, core.input<T> | undefined> {
3108
3130
  def: $ZodPrefaultDef<T>;
3109
3131
  optin: "optional";
3132
+ optout?: "optional" | undefined;
3110
3133
  isst: never;
3111
3134
  values: T["_zod"]["values"];
3112
3135
  }
@@ -3149,6 +3172,8 @@ export interface $ZodNonOptionalInternals<T extends SomeType = $ZodType>
3149
3172
  def: $ZodNonOptionalDef<T>;
3150
3173
  isst: errors.$ZodIssueInvalidType;
3151
3174
  values: T["_zod"]["values"];
3175
+ optin: "optional" | undefined;
3176
+ optout: "optional" | undefined;
3152
3177
  }
3153
3178
 
3154
3179
  export interface $ZodNonOptional<T extends SomeType = $ZodType> extends $ZodType {
@@ -3242,6 +3267,8 @@ export interface $ZodSuccessDef<T extends SomeType = $ZodType> extends $ZodTypeD
3242
3267
  export interface $ZodSuccessInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<boolean, core.input<T>> {
3243
3268
  def: $ZodSuccessDef<T>;
3244
3269
  isst: never;
3270
+ optin: T["_zod"]["optin"];
3271
+ optout: "optional" | undefined;
3245
3272
  }
3246
3273
 
3247
3274
  export interface $ZodSuccess<T extends SomeType = $ZodType> extends $ZodType {
@@ -227,9 +227,10 @@ export class JSONSchemaGenerator {
227
227
  case "unknown": {
228
228
  break;
229
229
  }
230
- case "undefined":
231
- case "never": {
232
- _json.not = {};
230
+ case "undefined": {
231
+ if (this.unrepresentable === "throw") {
232
+ throw new Error("Undefined cannot be represented in JSON Schema");
233
+ }
233
234
  break;
234
235
  }
235
236
  case "void": {
@@ -238,6 +239,10 @@ export class JSONSchemaGenerator {
238
239
  }
239
240
  break;
240
241
  }
242
+ case "never": {
243
+ _json.not = {};
244
+ break;
245
+ }
241
246
  case "date": {
242
247
  if (this.unrepresentable === "throw") {
243
248
  throw new Error("Date cannot be represented in JSON Schema");
@@ -1023,11 +1023,11 @@ export function partialRecord<Key extends core.$ZodRecordKey, Value extends Some
1023
1023
  keyType: Key,
1024
1024
  valueType: Value,
1025
1025
  params?: string | core.$ZodRecordParams
1026
- ): ZodMiniRecord<Key, ZodMiniOptional<Value>> {
1026
+ ): ZodMiniRecord<Key & core.$partial, Value> {
1027
1027
  return new ZodMiniRecord({
1028
1028
  type: "record",
1029
1029
  keyType: union([keyType, never()]),
1030
- valueType: optional(valueType),
1030
+ valueType: valueType as any,
1031
1031
  ...util.normalizeParams(params),
1032
1032
  }) as any;
1033
1033
  }
@@ -717,7 +717,7 @@ function partialRecord(keyType, valueType, params) {
717
717
  return new exports.ZodRecord({
718
718
  type: "record",
719
719
  keyType: union([keyType, never()]),
720
- valueType: optional(valueType),
720
+ valueType: valueType,
721
721
  ...index_js_1.util.normalizeParams(params),
722
722
  });
723
723
  }
@@ -475,7 +475,7 @@ export interface ZodRecord<Key extends core.$ZodRecordKey = core.$ZodRecordKey,
475
475
  }
476
476
  export declare const ZodRecord: core.$constructor<ZodRecord>;
477
477
  export declare function record<Key extends core.$ZodRecordKey, Value extends core.SomeType>(keyType: Key, valueType: Value, params?: string | core.$ZodRecordParams): ZodRecord<Key, Value>;
478
- export declare function partialRecord<Key extends core.$ZodRecordKey, Value extends core.SomeType>(keyType: Key, valueType: Value, params?: string | core.$ZodRecordParams): ZodRecord<Key, ZodOptional<Value>>;
478
+ export declare function partialRecord<Key extends core.$ZodRecordKey, Value extends core.SomeType>(keyType: Key, valueType: Value, params?: string | core.$ZodRecordParams): ZodRecord<Key & core.$partial, Value>;
479
479
  export interface ZodMap<Key extends core.SomeType = core.$ZodType, Value extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodMapInternals<Key, Value>>, core.$ZodMap<Key, Value> {
480
480
  keyType: Key;
481
481
  valueType: Value;
@@ -475,7 +475,7 @@ export interface ZodRecord<Key extends core.$ZodRecordKey = core.$ZodRecordKey,
475
475
  }
476
476
  export declare const ZodRecord: core.$constructor<ZodRecord>;
477
477
  export declare function record<Key extends core.$ZodRecordKey, Value extends core.SomeType>(keyType: Key, valueType: Value, params?: string | core.$ZodRecordParams): ZodRecord<Key, Value>;
478
- export declare function partialRecord<Key extends core.$ZodRecordKey, Value extends core.SomeType>(keyType: Key, valueType: Value, params?: string | core.$ZodRecordParams): ZodRecord<Key, ZodOptional<Value>>;
478
+ export declare function partialRecord<Key extends core.$ZodRecordKey, Value extends core.SomeType>(keyType: Key, valueType: Value, params?: string | core.$ZodRecordParams): ZodRecord<Key & core.$partial, Value>;
479
479
  export interface ZodMap<Key extends core.SomeType = core.$ZodType, Value extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodMapInternals<Key, Value>>, core.$ZodMap<Key, Value> {
480
480
  keyType: Key;
481
481
  valueType: Value;
@@ -612,7 +612,7 @@ export function partialRecord(keyType, valueType, params) {
612
612
  return new ZodRecord({
613
613
  type: "record",
614
614
  keyType: union([keyType, never()]),
615
- valueType: optional(valueType),
615
+ valueType: valueType,
616
616
  ...util.normalizeParams(params),
617
617
  });
618
618
  }
@@ -635,6 +635,8 @@ export interface $ZodIntersectionDef<Left extends SomeType = $ZodType, Right ext
635
635
  export interface $ZodIntersectionInternals<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodTypeInternals<core.output<A> & core.output<B>, core.input<A> & core.input<B>> {
636
636
  def: $ZodIntersectionDef<A, B>;
637
637
  isst: never;
638
+ optin: A["_zod"]["optin"] | B["_zod"]["optin"];
639
+ optout: A["_zod"]["optout"] | B["_zod"]["optout"];
638
640
  }
639
641
  export interface $ZodIntersection<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodType {
640
642
  _zod: $ZodIntersectionInternals<A, B>;
@@ -681,12 +683,17 @@ export interface $ZodRecordDef<Key extends $ZodRecordKey = $ZodRecordKey, Value
681
683
  keyType: Key;
682
684
  valueType: Value;
683
685
  }
684
- export type $InferZodRecordOutput<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> = undefined extends Key["_zod"]["values"] ? string extends core.output<Key> ? Record<core.output<Key>, core.output<Value>> : number extends core.output<Key> ? Record<core.output<Key>, core.output<Value>> : symbol extends core.output<Key> ? Record<core.output<Key>, core.output<Value>> : Record<core.output<Key>, core.output<Value>> : Record<core.output<Key>, core.output<Value>>;
685
- export type $InferZodRecordInput<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> = undefined extends Key["_zod"]["values"] ? string extends core.input<Key> ? Record<core.input<Key>, core.input<Value>> : number extends core.input<Key> ? Record<core.input<Key>, core.input<Value>> : symbol extends core.input<Key> ? Record<core.input<Key>, core.input<Value>> : Record<core.input<Key>, core.input<Value>> : Record<core.input<Key>, core.input<Value>>;
686
+ export type $InferZodRecordOutput<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> = Key extends $partial ? Partial<Record<core.output<Key>, core.output<Value>>> : Record<core.output<Key>, core.output<Value>>;
687
+ export type $InferZodRecordInput<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> = Key extends $partial ? Partial<Record<core.input<Key>, core.input<Value>>> : Record<core.input<Key>, core.input<Value>>;
686
688
  export interface $ZodRecordInternals<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> extends $ZodTypeInternals<$InferZodRecordOutput<Key, Value>, $InferZodRecordInput<Key, Value>> {
687
689
  def: $ZodRecordDef<Key, Value>;
688
690
  isst: errors.$ZodIssueInvalidType | errors.$ZodIssueInvalidKey<Record<PropertyKey, unknown>>;
691
+ optin?: "optional" | undefined;
692
+ optout?: "optional" | undefined;
689
693
  }
694
+ export type $partial = {
695
+ "~~partial": true;
696
+ };
690
697
  export interface $ZodRecord<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> extends $ZodType {
691
698
  _zod: $ZodRecordInternals<Key, Value>;
692
699
  }
@@ -699,6 +706,8 @@ export interface $ZodMapDef<Key extends SomeType = $ZodType, Value extends SomeT
699
706
  export interface $ZodMapInternals<Key extends SomeType = $ZodType, Value extends SomeType = $ZodType> extends $ZodTypeInternals<Map<core.output<Key>, core.output<Value>>, Map<core.input<Key>, core.input<Value>>> {
700
707
  def: $ZodMapDef<Key, Value>;
701
708
  isst: errors.$ZodIssueInvalidType | errors.$ZodIssueInvalidKey | errors.$ZodIssueInvalidElement<unknown>;
709
+ optin?: "optional" | undefined;
710
+ optout?: "optional" | undefined;
702
711
  }
703
712
  export interface $ZodMap<Key extends SomeType = $ZodType, Value extends SomeType = $ZodType> extends $ZodType {
704
713
  _zod: $ZodMapInternals<Key, Value>;
@@ -711,6 +720,8 @@ export interface $ZodSetDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
711
720
  export interface $ZodSetInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<Set<core.output<T>>, Set<core.input<T>>> {
712
721
  def: $ZodSetDef<T>;
713
722
  isst: errors.$ZodIssueInvalidType;
723
+ optin?: "optional" | undefined;
724
+ optout?: "optional" | undefined;
714
725
  }
715
726
  export interface $ZodSet<T extends SomeType = $ZodType> extends $ZodType {
716
727
  _zod: $ZodSetInternals<T>;
@@ -823,6 +834,7 @@ export interface $ZodDefaultDef<T extends SomeType = $ZodType> extends $ZodTypeD
823
834
  export interface $ZodDefaultInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<util.NoUndefined<core.output<T>>, core.input<T> | undefined> {
824
835
  def: $ZodDefaultDef<T>;
825
836
  optin: "optional";
837
+ optout?: "optional" | undefined;
826
838
  isst: never;
827
839
  values: T["_zod"]["values"];
828
840
  }
@@ -839,6 +851,7 @@ export interface $ZodPrefaultDef<T extends SomeType = $ZodType> extends $ZodType
839
851
  export interface $ZodPrefaultInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<util.NoUndefined<core.output<T>>, core.input<T> | undefined> {
840
852
  def: $ZodPrefaultDef<T>;
841
853
  optin: "optional";
854
+ optout?: "optional" | undefined;
842
855
  isst: never;
843
856
  values: T["_zod"]["values"];
844
857
  }
@@ -854,6 +867,8 @@ export interface $ZodNonOptionalInternals<T extends SomeType = $ZodType> extends
854
867
  def: $ZodNonOptionalDef<T>;
855
868
  isst: errors.$ZodIssueInvalidType;
856
869
  values: T["_zod"]["values"];
870
+ optin: "optional" | undefined;
871
+ optout: "optional" | undefined;
857
872
  }
858
873
  export interface $ZodNonOptional<T extends SomeType = $ZodType> extends $ZodType {
859
874
  _zod: $ZodNonOptionalInternals<T>;
@@ -866,6 +881,8 @@ export interface $ZodSuccessDef<T extends SomeType = $ZodType> extends $ZodTypeD
866
881
  export interface $ZodSuccessInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<boolean, core.input<T>> {
867
882
  def: $ZodSuccessDef<T>;
868
883
  isst: never;
884
+ optin: T["_zod"]["optin"];
885
+ optout: "optional" | undefined;
869
886
  }
870
887
  export interface $ZodSuccess<T extends SomeType = $ZodType> extends $ZodType {
871
888
  _zod: $ZodSuccessInternals<T>;
@@ -635,6 +635,8 @@ export interface $ZodIntersectionDef<Left extends SomeType = $ZodType, Right ext
635
635
  export interface $ZodIntersectionInternals<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodTypeInternals<core.output<A> & core.output<B>, core.input<A> & core.input<B>> {
636
636
  def: $ZodIntersectionDef<A, B>;
637
637
  isst: never;
638
+ optin: A["_zod"]["optin"] | B["_zod"]["optin"];
639
+ optout: A["_zod"]["optout"] | B["_zod"]["optout"];
638
640
  }
639
641
  export interface $ZodIntersection<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodType {
640
642
  _zod: $ZodIntersectionInternals<A, B>;
@@ -681,12 +683,17 @@ export interface $ZodRecordDef<Key extends $ZodRecordKey = $ZodRecordKey, Value
681
683
  keyType: Key;
682
684
  valueType: Value;
683
685
  }
684
- export type $InferZodRecordOutput<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> = undefined extends Key["_zod"]["values"] ? string extends core.output<Key> ? Record<core.output<Key>, core.output<Value>> : number extends core.output<Key> ? Record<core.output<Key>, core.output<Value>> : symbol extends core.output<Key> ? Record<core.output<Key>, core.output<Value>> : Record<core.output<Key>, core.output<Value>> : Record<core.output<Key>, core.output<Value>>;
685
- export type $InferZodRecordInput<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> = undefined extends Key["_zod"]["values"] ? string extends core.input<Key> ? Record<core.input<Key>, core.input<Value>> : number extends core.input<Key> ? Record<core.input<Key>, core.input<Value>> : symbol extends core.input<Key> ? Record<core.input<Key>, core.input<Value>> : Record<core.input<Key>, core.input<Value>> : Record<core.input<Key>, core.input<Value>>;
686
+ export type $InferZodRecordOutput<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> = Key extends $partial ? Partial<Record<core.output<Key>, core.output<Value>>> : Record<core.output<Key>, core.output<Value>>;
687
+ export type $InferZodRecordInput<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> = Key extends $partial ? Partial<Record<core.input<Key>, core.input<Value>>> : Record<core.input<Key>, core.input<Value>>;
686
688
  export interface $ZodRecordInternals<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> extends $ZodTypeInternals<$InferZodRecordOutput<Key, Value>, $InferZodRecordInput<Key, Value>> {
687
689
  def: $ZodRecordDef<Key, Value>;
688
690
  isst: errors.$ZodIssueInvalidType | errors.$ZodIssueInvalidKey<Record<PropertyKey, unknown>>;
691
+ optin?: "optional" | undefined;
692
+ optout?: "optional" | undefined;
689
693
  }
694
+ export type $partial = {
695
+ "~~partial": true;
696
+ };
690
697
  export interface $ZodRecord<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> extends $ZodType {
691
698
  _zod: $ZodRecordInternals<Key, Value>;
692
699
  }
@@ -699,6 +706,8 @@ export interface $ZodMapDef<Key extends SomeType = $ZodType, Value extends SomeT
699
706
  export interface $ZodMapInternals<Key extends SomeType = $ZodType, Value extends SomeType = $ZodType> extends $ZodTypeInternals<Map<core.output<Key>, core.output<Value>>, Map<core.input<Key>, core.input<Value>>> {
700
707
  def: $ZodMapDef<Key, Value>;
701
708
  isst: errors.$ZodIssueInvalidType | errors.$ZodIssueInvalidKey | errors.$ZodIssueInvalidElement<unknown>;
709
+ optin?: "optional" | undefined;
710
+ optout?: "optional" | undefined;
702
711
  }
703
712
  export interface $ZodMap<Key extends SomeType = $ZodType, Value extends SomeType = $ZodType> extends $ZodType {
704
713
  _zod: $ZodMapInternals<Key, Value>;
@@ -711,6 +720,8 @@ export interface $ZodSetDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
711
720
  export interface $ZodSetInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<Set<core.output<T>>, Set<core.input<T>>> {
712
721
  def: $ZodSetDef<T>;
713
722
  isst: errors.$ZodIssueInvalidType;
723
+ optin?: "optional" | undefined;
724
+ optout?: "optional" | undefined;
714
725
  }
715
726
  export interface $ZodSet<T extends SomeType = $ZodType> extends $ZodType {
716
727
  _zod: $ZodSetInternals<T>;
@@ -823,6 +834,7 @@ export interface $ZodDefaultDef<T extends SomeType = $ZodType> extends $ZodTypeD
823
834
  export interface $ZodDefaultInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<util.NoUndefined<core.output<T>>, core.input<T> | undefined> {
824
835
  def: $ZodDefaultDef<T>;
825
836
  optin: "optional";
837
+ optout?: "optional" | undefined;
826
838
  isst: never;
827
839
  values: T["_zod"]["values"];
828
840
  }
@@ -839,6 +851,7 @@ export interface $ZodPrefaultDef<T extends SomeType = $ZodType> extends $ZodType
839
851
  export interface $ZodPrefaultInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<util.NoUndefined<core.output<T>>, core.input<T> | undefined> {
840
852
  def: $ZodPrefaultDef<T>;
841
853
  optin: "optional";
854
+ optout?: "optional" | undefined;
842
855
  isst: never;
843
856
  values: T["_zod"]["values"];
844
857
  }
@@ -854,6 +867,8 @@ export interface $ZodNonOptionalInternals<T extends SomeType = $ZodType> extends
854
867
  def: $ZodNonOptionalDef<T>;
855
868
  isst: errors.$ZodIssueInvalidType;
856
869
  values: T["_zod"]["values"];
870
+ optin: "optional" | undefined;
871
+ optout: "optional" | undefined;
857
872
  }
858
873
  export interface $ZodNonOptional<T extends SomeType = $ZodType> extends $ZodType {
859
874
  _zod: $ZodNonOptionalInternals<T>;
@@ -866,6 +881,8 @@ export interface $ZodSuccessDef<T extends SomeType = $ZodType> extends $ZodTypeD
866
881
  export interface $ZodSuccessInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<boolean, core.input<T>> {
867
882
  def: $ZodSuccessDef<T>;
868
883
  isst: never;
884
+ optin: T["_zod"]["optin"];
885
+ optout: "optional" | undefined;
869
886
  }
870
887
  export interface $ZodSuccess<T extends SomeType = $ZodType> extends $ZodType {
871
888
  _zod: $ZodSuccessInternals<T>;
@@ -151,9 +151,10 @@ class JSONSchemaGenerator {
151
151
  case "unknown": {
152
152
  break;
153
153
  }
154
- case "undefined":
155
- case "never": {
156
- _json.not = {};
154
+ case "undefined": {
155
+ if (this.unrepresentable === "throw") {
156
+ throw new Error("Undefined cannot be represented in JSON Schema");
157
+ }
157
158
  break;
158
159
  }
159
160
  case "void": {
@@ -162,6 +163,10 @@ class JSONSchemaGenerator {
162
163
  }
163
164
  break;
164
165
  }
166
+ case "never": {
167
+ _json.not = {};
168
+ break;
169
+ }
165
170
  case "date": {
166
171
  if (this.unrepresentable === "throw") {
167
172
  throw new Error("Date cannot be represented in JSON Schema");
@@ -147,9 +147,10 @@ export class JSONSchemaGenerator {
147
147
  case "unknown": {
148
148
  break;
149
149
  }
150
- case "undefined":
151
- case "never": {
152
- _json.not = {};
150
+ case "undefined": {
151
+ if (this.unrepresentable === "throw") {
152
+ throw new Error("Undefined cannot be represented in JSON Schema");
153
+ }
153
154
  break;
154
155
  }
155
156
  case "void": {
@@ -158,6 +159,10 @@ export class JSONSchemaGenerator {
158
159
  }
159
160
  break;
160
161
  }
162
+ case "never": {
163
+ _json.not = {};
164
+ break;
165
+ }
161
166
  case "date": {
162
167
  if (this.unrepresentable === "throw") {
163
168
  throw new Error("Date cannot be represented in JSON Schema");
@@ -565,7 +565,7 @@ function partialRecord(keyType, valueType, params) {
565
565
  return new exports.ZodMiniRecord({
566
566
  type: "record",
567
567
  keyType: union([keyType, never()]),
568
- valueType: optional(valueType),
568
+ valueType: valueType,
569
569
  ...index_js_1.util.normalizeParams(params),
570
570
  });
571
571
  }
@@ -234,7 +234,7 @@ export interface ZodMiniRecord<Key extends core.$ZodRecordKey = core.$ZodRecordK
234
234
  }
235
235
  export declare const ZodMiniRecord: core.$constructor<ZodMiniRecord>;
236
236
  export declare function record<Key extends core.$ZodRecordKey, Value extends SomeType>(keyType: Key, valueType: Value, params?: string | core.$ZodRecordParams): ZodMiniRecord<Key, Value>;
237
- export declare function partialRecord<Key extends core.$ZodRecordKey, Value extends SomeType>(keyType: Key, valueType: Value, params?: string | core.$ZodRecordParams): ZodMiniRecord<Key, ZodMiniOptional<Value>>;
237
+ export declare function partialRecord<Key extends core.$ZodRecordKey, Value extends SomeType>(keyType: Key, valueType: Value, params?: string | core.$ZodRecordParams): ZodMiniRecord<Key & core.$partial, Value>;
238
238
  export interface ZodMiniMap<Key extends SomeType = core.$ZodType, Value extends SomeType = core.$ZodType> extends _ZodMiniType<core.$ZodMapInternals<Key, Value>> {
239
239
  }
240
240
  export declare const ZodMiniMap: core.$constructor<ZodMiniMap>;
@@ -234,7 +234,7 @@ export interface ZodMiniRecord<Key extends core.$ZodRecordKey = core.$ZodRecordK
234
234
  }
235
235
  export declare const ZodMiniRecord: core.$constructor<ZodMiniRecord>;
236
236
  export declare function record<Key extends core.$ZodRecordKey, Value extends SomeType>(keyType: Key, valueType: Value, params?: string | core.$ZodRecordParams): ZodMiniRecord<Key, Value>;
237
- export declare function partialRecord<Key extends core.$ZodRecordKey, Value extends SomeType>(keyType: Key, valueType: Value, params?: string | core.$ZodRecordParams): ZodMiniRecord<Key, ZodMiniOptional<Value>>;
237
+ export declare function partialRecord<Key extends core.$ZodRecordKey, Value extends SomeType>(keyType: Key, valueType: Value, params?: string | core.$ZodRecordParams): ZodMiniRecord<Key & core.$partial, Value>;
238
238
  export interface ZodMiniMap<Key extends SomeType = core.$ZodType, Value extends SomeType = core.$ZodType> extends _ZodMiniType<core.$ZodMapInternals<Key, Value>> {
239
239
  }
240
240
  export declare const ZodMiniMap: core.$constructor<ZodMiniMap>;
@@ -455,7 +455,7 @@ export function partialRecord(keyType, valueType, params) {
455
455
  return new ZodMiniRecord({
456
456
  type: "record",
457
457
  keyType: union([keyType, never()]),
458
- valueType: optional(valueType),
458
+ valueType: valueType,
459
459
  ...util.normalizeParams(params),
460
460
  });
461
461
  }