zod 4.0.0-beta.20250503T014749 → 4.0.0-beta.20250504T224201

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.
@@ -10,14 +10,12 @@ export interface ZodType<out Output = unknown, out Input = unknown> extends core
10
10
  def: this["_zod"]["def"];
11
11
  /** @deprecated Use `.def` instead. */
12
12
  _def: this["_zod"]["def"];
13
- /** @deprecated Use `z.output<typeof schema>` instead. */
14
- _output: this["_zod"]["output"];
15
- /** @deprecated Use `z.input<typeof schema>` instead. */
16
- _input: this["_zod"]["input"];
17
- check(...checks: (core.CheckFn<this["_zod"]["output"]> | core.$ZodCheck<this["_zod"]["output"]>)[]): this;
13
+ _output: core.output<this>;
14
+ _input: core.input<this>;
15
+ check(...checks: (core.CheckFn<core.output<this>> | core.$ZodCheck<core.output<this>>)[]): this;
18
16
  clone(def?: this["_zod"]["def"]): this;
19
17
  register<R extends core.$ZodRegistry>(registry: R, ...meta: this extends R["_schema"] ? undefined extends R["_meta"] ? [core.$ZodRegistry<R["_meta"], this>["_meta"]?] : [core.$ZodRegistry<R["_meta"], this>["_meta"]] : ["Incompatible schema"]): this;
20
- brand<T extends PropertyKey = PropertyKey>(value?: T): this & Record<"_zod", Record<"output", this["_zod"]["output"] & core.$brand<T>>>;
18
+ brand<T extends PropertyKey = PropertyKey>(value?: T): PropertyKey extends T ? this : this & Record<"_zod", Record<"~output", core.output<this> & core.$brand<T>>>;
21
19
  parse(data: unknown, params?: core.ParseContext<core.$ZodIssue>): core.output<this>;
22
20
  safeParse(data: unknown, params?: core.ParseContext<core.$ZodIssue>): parse.ZodSafeParseResult<core.output<this>>;
23
21
  parseAsync(data: unknown, params?: core.ParseContext<core.$ZodIssue>): Promise<core.output<this>>;
@@ -387,78 +385,9 @@ export interface ZodArray<T extends core.$ZodType = core.$ZodType> extends ZodTy
387
385
  }
388
386
  export declare const ZodArray: core.$constructor<ZodArray>;
389
387
  export declare function array<T extends core.$ZodType>(element: T, params?: string | core.$ZodArrayParams): ZodArray<T>;
390
- export interface ZodObjectLike<out O = object, out I = object> extends ZodType {
391
- _zod: core.$ZodObjectLikeInternals<O, I>;
392
- }
393
- export declare const ZodObjectLike: core.$constructor<ZodObjectLike>;
394
- export declare function keyof<T extends ZodObject>(schema: T): ZodLiteral<keyof T["_zod"]["def"]["shape"]>;
395
- export declare function keyof<T extends ZodInterface>(schema: T): ZodLiteral<keyof T["_zod"]["output"]>;
396
- type ZodInterfacePartial<T extends ZodInterface, Keys extends keyof T["_zod"]["def"]["shape"] = keyof T["_zod"]["def"]["shape"]> = ZodInterface<util.Extend<T["_zod"]["def"]["shape"], {
397
- [k in Keys]: ZodOptional<T["_zod"]["def"]["shape"][k]>;
398
- }>, {
399
- optional: T["_zod"]["optional"] | (string & Keys);
400
- defaulted: T["_zod"]["defaulted"];
401
- extra: T["_zod"]["extra"];
402
- }>;
403
- type ZodInterfaceRequired<T extends ZodInterface, Keys extends keyof T["_zod"]["def"]["shape"] = keyof T["_zod"]["def"]["shape"]> = ZodInterface<util.Extend<T["_zod"]["def"]["shape"], {
404
- [k in Keys]: ZodNonOptional<T["_zod"]["def"]["shape"][k]>;
405
- }>, {
406
- optional: never;
407
- defaulted: T["_zod"]["defaulted"];
408
- extra: T["_zod"]["extra"];
409
- }>;
410
- export type MergeInterfaces<A extends ZodInterface, B extends ZodInterface> = ZodInterface<util.Extend<A["_zod"]["def"]["shape"], B["_zod"]["def"]["shape"]>, util.MergeInterfaceParams<A, B>>;
411
- export interface ZodInterface<out Shape extends core.$ZodLooseShape = core.$ZodLooseShape, out Params extends core.$ZodInterfaceNamedParams = core.$ZodInterfaceNamedParams> extends ZodType {
412
- _zod: core.$ZodInterfaceInternals<Shape, Params>;
413
- keyof(): ZodEnum<util.ToEnum<util.InterfaceKeys<string & keyof Shape>>>;
414
- catchall<T extends core.$ZodType>(schema: T): ZodInterface<Shape, {
415
- optional: Params["optional"];
416
- defaulted: Params["defaulted"];
417
- extra: Record<string, T["_zod"]["output"]>;
418
- }>;
419
- /** Consider `z.strictObject({ ...A.shape })` instead. */
420
- strict(): ZodInterface<Shape, {
421
- optional: Params["optional"];
422
- defaulted: Params["defaulted"];
423
- extra: {};
424
- }>;
425
- loose(): ZodInterface<Shape, {
426
- optional: Params["optional"];
427
- defaulted: Params["defaulted"];
428
- extra: Record<string, unknown>;
429
- }>;
430
- /** Use `z.looseObject({ ...A.shape })` instead. */
431
- strip(): ZodInterface<Shape, {
432
- optional: Params["optional"];
433
- defaulted: Params["defaulted"];
434
- extra: {};
435
- }>;
436
- extend<U extends ZodInterface>(int: U): MergeInterfaces<this, U>;
437
- extend<U extends core.$ZodLooseShape>(shape: U): MergeInterfaces<this, ZodInterface<U, util.InitInterfaceParams<U, {}>>>;
438
- /** @deprecated Use `A.extend(B)` */
439
- merge<U extends ZodInterface>(incoming: U): MergeInterfaces<this, U>;
440
- pick<const M extends util.Exactly<util.Mask<string & keyof Shape>, M>>(mask: M): ZodInterface<util.Flatten<Pick<Shape, keyof Shape & keyof M>>, {
441
- optional: Extract<Params["optional"], keyof M>;
442
- defaulted: Extract<Params["defaulted"], keyof M>;
443
- extra: Params["extra"];
444
- }>;
445
- omit<const M extends util.Exactly<util.Mask<string & keyof Shape>, M>>(mask: M): ZodInterface<util.Flatten<Omit<Shape, keyof M>>, {
446
- optional: Exclude<Params["optional"], keyof M>;
447
- defaulted: Exclude<Params["defaulted"], keyof M>;
448
- extra: Params["extra"];
449
- }>;
450
- partial(): ZodInterfacePartial<this>;
451
- partial<M extends util.Mask<string & keyof Shape>>(mask: M): ZodInterfacePartial<this, string & keyof M>;
452
- required(): ZodInterfaceRequired<this, string & keyof Shape>;
453
- required<M extends util.Mask<string & keyof Shape>>(mask: M): ZodInterfaceRequired<this, string & keyof M>;
454
- }
455
- export declare const ZodInterface: core.$constructor<ZodInterface>;
456
- declare function _interface<T extends core.$ZodLooseShape>(shape: T, params?: string | core.$ZodInterfaceParams, Class?: util.Constructor<ZodInterface>): ZodInterface<util.CleanInterfaceShape<T>, util.InitInterfaceParams<T, {}>>;
457
- export { _interface as interface };
458
- export declare function strictInterface<T extends core.$ZodLooseShape>(shape: T, params?: string | core.$ZodInterfaceParams): ZodInterface<util.CleanInterfaceShape<T>, util.InitInterfaceParams<T, {}>>;
459
- export declare function looseInterface<T extends core.$ZodLooseShape>(shape: T, params?: string | core.$ZodInterfaceParams): ZodInterface<util.CleanInterfaceShape<T>, util.InitInterfaceParams<T, Record<string, unknown>>>;
460
- export interface ZodObject<out Shape extends core.$ZodShape = core.$ZodShape, Extra extends Record<string, unknown> = Record<string, unknown>> extends ZodType {
461
- _zod: core.$ZodObjectInternals<Shape, Extra>;
388
+ export declare function keyof<T extends ZodObject>(schema: T): ZodLiteral<keyof T["_zod"]["output"]>;
389
+ export interface ZodObject<out Shape extends core.$ZodShape = core.$ZodLooseShape, OutExtra extends Record<string, unknown> = Record<string, unknown>, InExtra extends Record<string, unknown> = Record<string, unknown>> extends ZodType {
390
+ _zod: core.$ZodObjectInternals<Shape, OutExtra, InExtra>;
462
391
  shape: Shape;
463
392
  keyof(): ZodEnum<util.ToEnum<keyof Shape & string>>;
464
393
  /** Define a schema to validate all unrecognized keys. This overrides the existing strict/loose behavior. */
@@ -471,94 +400,50 @@ export interface ZodObject<out Shape extends core.$ZodShape = core.$ZodShape, Ex
471
400
  strict(): ZodObject<Shape, {}>;
472
401
  /** This is the default behavior. This method call is likely unnecessary. */
473
402
  strip(): ZodObject<Shape, {}>;
474
- extend<const U extends ZodObject>(schema: U): ZodObject<util.Extend<Shape, U["_zod"]["def"]["shape"]>, Extra>;
475
- extend<U extends core.$ZodShape>(shape: U): ZodObject<util.Extend<Shape, U>, Extra>;
476
- /** @deprecated Use `A.extend(B.shape)` */
477
- merge<U extends ZodObject<any, any>>(other: U): ZodObject<util.Flatten<util.Extend<Shape, U["_zod"]["def"]["shape"]>>, Extra>;
478
- pick<M extends util.Exactly<util.Mask<string & keyof Shape>, M>>(mask: M): ZodObject<util.Flatten<Pick<Shape, Extract<keyof Shape, keyof M>>>, Extra>;
479
- omit<M extends util.Exactly<util.Mask<string & keyof Shape>, M>>(mask: M): ZodObject<util.Flatten<Omit<Shape, Extract<keyof Shape, keyof M>>>, Extra>;
403
+ extend<U extends core.$ZodLooseShape>(shape: U): ZodObject<util.Extend<Shape, U>, OutExtra, InExtra>;
404
+ /**
405
+ * @deprecated Use destructuring to merge the shapes:
406
+ *
407
+ * ```ts
408
+ * z.object({
409
+ * ...A.shape,
410
+ * ...B.shape
411
+ * });
412
+ * ```
413
+ */
414
+ merge<U extends ZodObject>(other: U): ZodObject<util.Extend<Shape, U["shape"]>, U["_zod"]["outextra"], U["_zod"]["inextra"]>;
415
+ /**
416
+ * @deprecated Use destructuring to merge the shapes:
417
+ *
418
+ * ```ts
419
+ * z.object({
420
+ * ...A.shape,
421
+ * ...B.shape
422
+ * });
423
+ * ```
424
+ */
425
+ pick<M extends util.Exactly<util.Mask<string & keyof Shape>, M>>(mask: M): ZodObject<util.Flatten<Pick<Shape, Extract<keyof Shape, keyof M>>>, OutExtra, InExtra>;
426
+ omit<M extends util.Exactly<util.Mask<string & keyof Shape>, M>>(mask: M): ZodObject<util.Flatten<Omit<Shape, Extract<keyof Shape, keyof M>>>, OutExtra, InExtra>;
480
427
  partial(): ZodObject<{
481
428
  [k in keyof Shape]: ZodOptional<Shape[k]>;
482
- }, Extra>;
429
+ }, OutExtra, InExtra>;
483
430
  partial<M extends util.Exactly<util.Mask<string & keyof Shape>, M>>(mask: M): ZodObject<{
484
431
  [k in keyof Shape]: k extends keyof M ? ZodOptional<Shape[k]> : Shape[k];
485
- }, Extra>;
432
+ }, OutExtra, InExtra>;
486
433
  required(): ZodObject<{
487
434
  [k in keyof Shape]: ZodNonOptional<Shape[k]>;
488
- }, Extra>;
435
+ }, OutExtra, InExtra>;
489
436
  required<M extends util.Exactly<util.Mask<string & keyof Shape>, M>>(mask: M): ZodObject<{
490
437
  [k in keyof Shape]: k extends keyof M ? ZodNonOptional<Shape[k]> : Shape[k];
491
- }, Extra>;
438
+ }, OutExtra, InExtra>;
492
439
  }
493
440
  export declare const ZodObject: core.$constructor<ZodObject>;
494
- export declare function object<T extends core.$ZodShape = Record<never, core.$ZodType>>(shape?: T, params?: string | core.$ZodObjectLikeParams): ZodObject<T, {}>;
495
- export declare function strictObject<T extends core.$ZodShape>(shape: T, params?: string | core.$ZodObjectParams): ZodObject<T, {}>;
496
- export declare function looseObject<T extends core.$ZodShape>(shape: T, params?: string | core.$ZodObjectParams): ZodObject<T, {
441
+ export declare function object<T extends core.$ZodLooseShape = Record<never, core.$ZodType>>(shape?: T, params?: string | core.$ZodObjectParams): ZodObject<util.Writeable<T> & {}, {}, {}>;
442
+ export declare function strictObject<T extends core.$ZodLooseShape>(shape: T, params?: string | core.$ZodObjectParams): ZodObject<T, {}, {}>;
443
+ export declare function looseObject<T extends core.$ZodLooseShape>(shape: T, params?: string | core.$ZodObjectParams): ZodObject<T, {
497
444
  [k: string]: unknown;
498
- }>;
499
- export declare function extend<T extends ZodInterface, U extends ZodInterface>(a: T, b: U): ZodInterface<util.Extend<T["_zod"]["def"]["shape"], U["_zod"]["def"]["shape"]>, util.MergeInterfaceParams<T, U>>;
500
- export declare function extend<T extends ZodObject, U extends ZodObject>(a: T, b: U): ZodObject<util.Extend<T["_zod"]["def"]["shape"], U["_zod"]["def"]["shape"]>, U["_zod"]["extra"] & T["_zod"]["extra"]>;
501
- export declare function extend<T extends ZodObjectLike, U extends core.$ZodLooseShape>(schema: T, shape: U): T extends ZodInterface<infer TShape, infer TParams> ? ZodInterface<util.ExtendInterfaceShape<TShape, U>, util.ExtendInterfaceParams<ZodInterface<TShape, TParams>, U>> : ZodObject<util.Extend<T["_zod"]["def"]["shape"], U>, T["_zod"]["extra"]>;
502
- export declare function merge<T extends ZodObjectLike, U extends core.$ZodLooseShape>(schema: T, shape: U): T["_zod"]["def"]["type"] extends "interface" ? ZodInterface<util.Extend<T["_zod"]["def"]["shape"], U["_zod"]["def"]["shape"]>, {
503
- extra: T["_zod"]["extra"] & U["_zod"]["extra"];
504
- optional: Exclude<T["_zod"]["optional"], keyof U["_zod"]["def"]["shape"]> | U["_zod"]["optional"];
505
- defaulted: Exclude<T["_zod"]["defaulted"], keyof U["_zod"]["def"]["shape"]> | U["_zod"]["defaulted"];
506
- }> : ZodObject<util.Extend<T["_zod"]["def"]["shape"], U>, T["_zod"]["extra"]>;
507
- export declare function pick<T extends ZodObjectLike, M extends util.Exactly<util.Mask<keyof T["_zod"]["def"]["shape"]>, M>>(schema: T, mask: M): T["_zod"]["def"]["type"] extends "interface" ? ZodInterface<util.Flatten<Pick<T["_zod"]["def"]["shape"], keyof T["_zod"]["def"]["shape"] & keyof M>>, {
508
- optional: Extract<T["_zod"]["optional"], keyof M>;
509
- defaulted: Extract<T["_zod"]["defaulted"], keyof M>;
510
- extra: T["_zod"]["extra"];
511
- }> : ZodObject<util.Flatten<Pick<T["_zod"]["def"]["shape"], keyof T["_zod"]["def"]["shape"] & keyof M>>, T["_zod"]["extra"]>;
512
- export declare function omit<T extends ZodObjectLike, const M extends util.Exactly<util.Mask<keyof T["_zod"]["def"]["shape"]>, M>>(schema: T, mask: M): T["_zod"]["def"]["type"] extends "interface" ? ZodInterface<util.Flatten<Omit<T["_zod"]["def"]["shape"], keyof M>>, {
513
- optional: Exclude<T["_zod"]["optional"], keyof M>;
514
- defaulted: Exclude<T["_zod"]["defaulted"], keyof M>;
515
- extra: T["_zod"]["extra"];
516
- }> : ZodObject<util.Flatten<Omit<T["_zod"]["def"]["shape"], keyof M>>, T["_zod"]["extra"]>;
517
- export declare function partial<T extends ZodObjectLike>(schema: T): T["_zod"]["def"]["type"] extends "interface" ? ZodInterface<{
518
- [k in keyof T["_zod"]["def"]["shape"]]: ZodOptional<T["_zod"]["def"]["shape"][k]>;
519
445
  }, {
520
- optional: string & keyof T["_zod"]["def"]["shape"];
521
- defaulted: never;
522
- extra: T["_zod"]["extra"];
523
- }> : ZodObject<{
524
- [k in keyof T["_zod"]["def"]["shape"]]: ZodOptional<T["_zod"]["def"]["shape"][k]>;
525
- }, T["_zod"]["extra"]>;
526
- export declare function partial<T extends ZodObjectLike, M extends util.Exactly<util.Mask<keyof T["_zod"]["def"]["shape"]>, M>>(schema: T, mask: M): T["_zod"]["def"]["type"] extends "interface" ? ZodInterface<util.Extend<T["_zod"]["def"]["shape"], {
527
- [k in keyof M & keyof T["_zod"]["def"]["shape"]]: ZodOptional<T["_zod"]["def"]["shape"][k]>;
528
- }>, {
529
- optional: string & (T["_zod"]["optional"] | keyof M);
530
- defaulted: T["_zod"]["defaulted"];
531
- extra: T["_zod"]["extra"];
532
- }> : ZodObject<{
533
- [k in keyof T["_zod"]["def"]["shape"]]: k extends keyof M ? ZodOptional<T["_zod"]["def"]["shape"][k]> : T["_zod"]["def"]["shape"][k];
534
- }, T["_zod"]["extra"]>;
535
- export declare function required<T extends {
536
- _subtype: "object";
537
- } & ZodObject>(schema: T): ZodObject<{
538
- [k in keyof T["_zod"]["def"]["shape"]]: ZodNonOptional<T["_zod"]["def"]["shape"][k]>;
539
- }>;
540
- export declare function required<T extends {
541
- _subtype: "object";
542
- } & ZodObject, M extends util.Exactly<util.Mask<keyof T["_zod"]["def"]["shape"]>, M>>(schema: T, mask: M): ZodObject<util.Extend<T["_zod"]["def"]["shape"], {
543
- [k in keyof M & keyof T["_zod"]["def"]["shape"]]: ZodNonOptional<T["_zod"]["def"]["shape"][k]>;
544
- }>>;
545
- export declare function required<T extends {
546
- _subtype: "interface";
547
- } & ZodInterface>(schema: T): ZodInterface<{
548
- [k in keyof T["_zod"]["def"]["shape"]]: ZodNonOptional<T["_zod"]["def"]["shape"][k]>;
549
- }, {
550
- optional: never;
551
- defaulted: T["_zod"]["defaulted"];
552
- extra: T["_zod"]["extra"];
553
- }>;
554
- export declare function required<T extends {
555
- _subtype: "interface";
556
- } & ZodInterface, M extends util.Mask<keyof T["_zod"]["output"]>>(schema: T, mask: M): ZodInterface<util.Extend<T["_zod"]["def"]["shape"], {
557
- [k in keyof M & keyof T["_zod"]["def"]["shape"]]: ZodNonOptional<T["_zod"]["def"]["shape"][k]>;
558
- }>, {
559
- optional: Exclude<T["_zod"]["optional"], keyof M>;
560
- defaulted: T["_zod"]["defaulted"];
561
- extra: T["_zod"]["extra"];
446
+ [k: string]: unknown;
562
447
  }>;
563
448
  export interface ZodUnion<T extends readonly core.$ZodType[] = readonly core.$ZodType[]> extends ZodType {
564
449
  _zod: core.$ZodUnionInternals<T>;
@@ -23,8 +23,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.ZodEnum = exports.ZodSet = exports.ZodMap = exports.ZodRecord = exports.ZodTuple = exports.ZodIntersection = exports.ZodDiscriminatedUnion = exports.ZodUnion = exports.ZodObject = exports.ZodInterface = exports.ZodObjectLike = exports.ZodArray = exports.ZodDate = exports.ZodVoid = exports.ZodNever = exports.ZodUnknown = exports.ZodAny = exports.ZodNull = exports.ZodUndefined = exports.ZodSymbol = exports.ZodBigIntFormat = exports.ZodBigInt = exports.ZodBoolean = exports.ZodNumberFormat = exports.ZodNumber = exports.ZodJWT = exports.ZodE164 = exports.ZodBase64URL = exports.ZodBase64 = exports.ZodCIDRv6 = exports.ZodCIDRv4 = exports.ZodIPv6 = exports.ZodIPv4 = exports.ZodKSUID = exports.ZodXID = exports.ZodULID = exports.ZodCUID2 = exports.ZodCUID = exports.ZodNanoID = exports.ZodEmoji = exports.ZodURL = exports.ZodUUID = exports.ZodGUID = exports.ZodEmail = exports.ZodStringFormat = exports.ZodString = exports._ZodString = exports.ZodType = exports.coerce = exports.iso = void 0;
27
- exports.stringbool = exports.ZodCustom = exports.ZodPromise = exports.ZodLazy = exports.ZodTemplateLiteral = exports.ZodReadonly = exports.ZodPipe = exports.ZodNaN = exports.ZodCatch = exports.ZodSuccess = exports.ZodNonOptional = exports.ZodDefault = exports.ZodNullable = exports.ZodOptional = exports.ZodTransform = exports.ZodFile = exports.ZodLiteral = void 0;
26
+ exports.ZodFile = exports.ZodLiteral = exports.ZodEnum = exports.ZodSet = exports.ZodMap = exports.ZodRecord = exports.ZodTuple = exports.ZodIntersection = exports.ZodDiscriminatedUnion = exports.ZodUnion = exports.ZodObject = exports.ZodArray = exports.ZodDate = exports.ZodVoid = exports.ZodNever = exports.ZodUnknown = exports.ZodAny = exports.ZodNull = exports.ZodUndefined = exports.ZodSymbol = exports.ZodBigIntFormat = exports.ZodBigInt = exports.ZodBoolean = exports.ZodNumberFormat = exports.ZodNumber = exports.ZodJWT = exports.ZodE164 = exports.ZodBase64URL = exports.ZodBase64 = exports.ZodCIDRv6 = exports.ZodCIDRv4 = exports.ZodIPv6 = exports.ZodIPv4 = exports.ZodKSUID = exports.ZodXID = exports.ZodULID = exports.ZodCUID2 = exports.ZodCUID = exports.ZodNanoID = exports.ZodEmoji = exports.ZodURL = exports.ZodUUID = exports.ZodGUID = exports.ZodEmail = exports.ZodStringFormat = exports.ZodString = exports._ZodString = exports.ZodType = exports.coerce = exports.iso = void 0;
27
+ exports.stringbool = exports.ZodCustom = exports.ZodPromise = exports.ZodLazy = exports.ZodTemplateLiteral = exports.ZodReadonly = exports.ZodPipe = exports.ZodNaN = exports.ZodCatch = exports.ZodSuccess = exports.ZodNonOptional = exports.ZodDefault = exports.ZodNullable = exports.ZodOptional = exports.ZodTransform = void 0;
28
28
  exports.string = string;
29
29
  exports.email = email;
30
30
  exports.guid = guid;
@@ -68,18 +68,9 @@ exports.void = _void;
68
68
  exports.date = date;
69
69
  exports.array = array;
70
70
  exports.keyof = keyof;
71
- exports.interface = _interface;
72
- exports.strictInterface = strictInterface;
73
- exports.looseInterface = looseInterface;
74
71
  exports.object = object;
75
72
  exports.strictObject = strictObject;
76
73
  exports.looseObject = looseObject;
77
- exports.extend = extend;
78
- exports.merge = merge;
79
- exports.pick = pick;
80
- exports.omit = omit;
81
- exports.partial = partial;
82
- exports.required = required;
83
74
  exports.union = union;
84
75
  exports.discriminatedUnion = discriminatedUnion;
85
76
  exports.intersection = intersection;
@@ -576,95 +567,17 @@ exports.ZodArray = core.$constructor("ZodArray", (inst, def) => {
576
567
  function array(element, params) {
577
568
  return core._array(exports.ZodArray, element, params);
578
569
  }
579
- exports.ZodObjectLike = core.$constructor("ZodObjectLike", (inst, def) => {
580
- core.$ZodObjectLike.init(inst, def);
581
- exports.ZodType.init(inst, def);
582
- });
570
+ // .keyof
583
571
  function keyof(schema) {
584
- const shape = schema._zod.def.type === "interface"
585
- ? core_1.util.cleanInterfaceShape(schema._zod.def.shape).shape
586
- : schema._zod.def.shape;
572
+ const shape = schema._zod.def.shape;
587
573
  return literal(Object.keys(shape));
588
574
  }
589
- exports.ZodInterface = core.$constructor("ZodInterface", (inst, def) => {
590
- core.$ZodInterface.init(inst, def);
591
- exports.ZodType.init(inst, def);
592
- // util.defineLazy(inst._zod, "shape", () => def.shape);
593
- inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
594
- inst.catchall = (catchall) => inst.clone({ ...inst._zod.def, catchall });
595
- inst.loose = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
596
- inst.strict = () => inst.clone({ ...inst._zod.def, catchall: never() });
597
- inst.strip = () => inst.clone({ ...inst._zod.def, catchall: undefined });
598
- inst.extend = (incoming) => {
599
- if (incoming instanceof core.$ZodInterface)
600
- return core_1.util.extendObjectLike(inst, incoming);
601
- return core_1.util.extendObjectLike(inst, _interface(incoming));
602
- };
603
- inst.merge = (other) => core_1.util.mergeObjectLike(inst, other);
604
- inst.pick = (mask) => core_1.util.pick(inst, mask);
605
- inst.omit = (mask) => core_1.util.omit(inst, mask);
606
- inst.partial = (...args) => core_1.util.partialObjectLike(exports.ZodOptional, inst, args[0]);
607
- inst.required = (...args) => core_1.util.requiredObjectLike(exports.ZodNonOptional, inst, args[0]);
608
- });
609
- function _interface(shape, params, Class = exports.ZodInterface) {
610
- const cleaned = core_1.util.cached(() => core_1.util.cleanInterfaceShape(shape));
611
- const def = {
612
- type: "interface",
613
- get shape() {
614
- // return cleaned.value.shape;
615
- const _shape = cleaned.value.shape;
616
- core_1.util.assignProp(this, "shape", _shape);
617
- return _shape;
618
- },
619
- get optional() {
620
- return cleaned.value.optional;
621
- },
622
- ...core_1.util.normalizeParams(params),
623
- };
624
- return new Class(def);
625
- }
626
- // strictInterface
627
- function strictInterface(shape, params) {
628
- const cleaned = core_1.util.cached(() => core_1.util.cleanInterfaceShape(shape));
629
- const def = {
630
- type: "interface",
631
- get shape() {
632
- // return cleaned.value.shape;
633
- const _shape = cleaned.value.shape;
634
- core_1.util.assignProp(this, "shape", _shape);
635
- return _shape;
636
- },
637
- get optional() {
638
- return cleaned.value.optional;
639
- },
640
- catchall: never(),
641
- ...core_1.util.normalizeParams(params),
642
- };
643
- return new exports.ZodInterface(def);
644
- }
645
- // looseInterface
646
- function looseInterface(shape, params) {
647
- const cleaned = core_1.util.cached(() => core_1.util.cleanInterfaceShape(shape));
648
- const def = {
649
- type: "interface",
650
- get optional() {
651
- return cleaned.value.optional;
652
- },
653
- get shape() {
654
- // return cleaned.value.shape;
655
- const _shape = cleaned.value.shape;
656
- core_1.util.assignProp(this, "shape", _shape);
657
- return _shape;
658
- },
659
- catchall: unknown(),
660
- ...core_1.util.normalizeParams(params),
661
- };
662
- return new exports.ZodInterface(def);
663
- }
664
575
  exports.ZodObject = core.$constructor("ZodObject", (inst, def) => {
665
576
  core.$ZodObject.init(inst, def);
666
577
  exports.ZodType.init(inst, def);
667
- inst.shape = def.shape;
578
+ core_1.util.defineLazy(inst, "shape", () => {
579
+ return Object.fromEntries(Object.entries(inst._zod.def.shape));
580
+ });
668
581
  inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
669
582
  inst.catchall = (catchall) => inst.clone({ ...inst._zod.def, catchall });
670
583
  inst.passthrough = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
@@ -673,22 +586,20 @@ exports.ZodObject = core.$constructor("ZodObject", (inst, def) => {
673
586
  inst.strict = () => inst.clone({ ...inst._zod.def, catchall: never() });
674
587
  inst.strip = () => inst.clone({ ...inst._zod.def, catchall: undefined });
675
588
  inst.extend = (incoming) => {
676
- if (incoming instanceof exports.ZodObject)
677
- return core_1.util.extendObjectLike(inst, incoming);
678
- return core_1.util.extendObjectLike(inst, object(incoming));
589
+ return core_1.util.extend(inst, incoming);
679
590
  };
680
- inst.merge = (other) => core_1.util.mergeObjectLike(inst, other);
591
+ inst.merge = (other) => core_1.util.merge(inst, other);
681
592
  inst.pick = (mask) => core_1.util.pick(inst, mask);
682
593
  inst.omit = (mask) => core_1.util.omit(inst, mask);
683
- inst.partial = (...args) => core_1.util.partialObjectLike(exports.ZodOptional, inst, args[0]);
684
- inst.required = (...args) => core_1.util.requiredObjectLike(exports.ZodNonOptional, inst, args[0]);
594
+ inst.partial = (...args) => core_1.util.partial(exports.ZodOptional, inst, args[0]);
595
+ inst.required = (...args) => core_1.util.required(exports.ZodNonOptional, inst, args[0]);
685
596
  });
686
597
  function object(shape, params) {
687
598
  const def = {
688
599
  type: "object",
689
- shape: shape ?? {},
690
- get optional() {
691
- return core_1.util.optionalObjectKeys(shape ?? {});
600
+ get shape() {
601
+ core_1.util.assignProp(this, "shape", { ...shape });
602
+ return this.shape;
692
603
  },
693
604
  ...core_1.util.normalizeParams(params),
694
605
  };
@@ -698,9 +609,9 @@ function object(shape, params) {
698
609
  function strictObject(shape, params) {
699
610
  return new exports.ZodObject({
700
611
  type: "object",
701
- shape: shape,
702
- get optional() {
703
- return core_1.util.optionalObjectKeys(shape);
612
+ get shape() {
613
+ core_1.util.assignProp(this, "shape", { ...shape });
614
+ return this.shape;
704
615
  },
705
616
  catchall: never(),
706
617
  ...core_1.util.normalizeParams(params),
@@ -710,40 +621,14 @@ function strictObject(shape, params) {
710
621
  function looseObject(shape, params) {
711
622
  return new exports.ZodObject({
712
623
  type: "object",
713
- shape: shape,
714
- get optional() {
715
- return core_1.util.optionalObjectKeys(shape);
624
+ get shape() {
625
+ core_1.util.assignProp(this, "shape", { ...shape });
626
+ return this.shape;
716
627
  },
717
628
  catchall: unknown(),
718
629
  ...core_1.util.normalizeParams(params),
719
630
  });
720
631
  }
721
- function extend(schema, shape) {
722
- if (shape instanceof core.$ZodType)
723
- return core_1.util.mergeObjectLike(schema, shape);
724
- if (schema instanceof exports.ZodInterface) {
725
- return core_1.util.mergeObjectLike(schema, _interface(shape));
726
- }
727
- if (schema instanceof exports.ZodObject)
728
- return core_1.util.mergeObjectLike(schema, object(shape));
729
- return core_1.util.extend(schema, shape);
730
- }
731
- function merge(a, b) {
732
- return core_1.util.mergeObjectLike(a, b);
733
- }
734
- function pick(schema, mask) {
735
- // const picked = util.pick(schema, mask);
736
- return core_1.util.pick(schema, mask);
737
- }
738
- function omit(schema, mask) {
739
- return core_1.util.omit(schema, mask);
740
- }
741
- function partial(schema, mask) {
742
- return core_1.util.partialObjectLike(exports.ZodOptional, schema, mask);
743
- }
744
- function required(schema, mask) {
745
- return core_1.util.requiredObjectLike(exports.ZodNonOptional, schema, mask);
746
- }
747
632
  exports.ZodUnion = core.$constructor("ZodUnion", (inst, def) => {
748
633
  core.$ZodUnion.init(inst, def);
749
634
  exports.ZodType.init(inst, def);