zod 4.0.0-beta.20250430T185432 → 4.0.0-beta.20250504T215252
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/dist/commonjs/schemas.d.ts +45 -155
- package/dist/commonjs/schemas.js +22 -133
- package/dist/esm/schemas.d.ts +45 -155
- package/dist/esm/schemas.js +20 -124
- package/package.json +2 -2
- package/src/schemas.ts +87 -478
|
@@ -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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
|
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>>;
|
|
@@ -248,7 +246,7 @@ export interface _ZodNumber<Input = unknown> extends ZodType {
|
|
|
248
246
|
max(value: number, params?: string | core.$ZodCheckLessThanParams): this;
|
|
249
247
|
/** Consider `z.int()` instead. This API is considered *legacy*; it will never be removed but a better alternative exists. */
|
|
250
248
|
int(params?: string | core.$ZodCheckNumberFormatParams): this;
|
|
251
|
-
/** @deprecated This is now identical to `.int()
|
|
249
|
+
/** @deprecated This is now identical to `.int()`. Only numbers in the safe integer range are accepted. */
|
|
252
250
|
safe(params?: string | core.$ZodCheckNumberFormatParams): this;
|
|
253
251
|
positive(params?: string | core.$ZodCheckGreaterThanParams): this;
|
|
254
252
|
nonnegative(params?: string | core.$ZodCheckGreaterThanParams): this;
|
|
@@ -387,175 +385,67 @@ 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
|
|
391
|
-
|
|
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
|
-
strict(): ZodInterface<Shape, {
|
|
420
|
-
optional: Params["optional"];
|
|
421
|
-
defaulted: Params["defaulted"];
|
|
422
|
-
extra: {};
|
|
423
|
-
}>;
|
|
424
|
-
loose(): ZodInterface<Shape, {
|
|
425
|
-
optional: Params["optional"];
|
|
426
|
-
defaulted: Params["defaulted"];
|
|
427
|
-
extra: Record<string, unknown>;
|
|
428
|
-
}>;
|
|
429
|
-
strip(): ZodInterface<Shape, {
|
|
430
|
-
optional: Params["optional"];
|
|
431
|
-
defaulted: Params["defaulted"];
|
|
432
|
-
extra: {};
|
|
433
|
-
}>;
|
|
434
|
-
extend<U extends ZodInterface>(int: U): MergeInterfaces<this, U>;
|
|
435
|
-
extend<U extends core.$ZodLooseShape>(shape: U): MergeInterfaces<this, ZodInterface<U, util.InitInterfaceParams<U, {}>>>;
|
|
436
|
-
/** @deprecated Use `A.extend(B)` */
|
|
437
|
-
merge<U extends ZodInterface>(incoming: U): MergeInterfaces<this, U>;
|
|
438
|
-
pick<const M extends util.Exactly<util.Mask<string & keyof Shape>, M>>(mask: M): ZodInterface<util.Flatten<Pick<Shape, keyof Shape & keyof M>>, {
|
|
439
|
-
optional: Extract<Params["optional"], keyof M>;
|
|
440
|
-
defaulted: Extract<Params["defaulted"], keyof M>;
|
|
441
|
-
extra: Params["extra"];
|
|
442
|
-
}>;
|
|
443
|
-
omit<const M extends util.Exactly<util.Mask<string & keyof Shape>, M>>(mask: M): ZodInterface<util.Flatten<Omit<Shape, keyof M>>, {
|
|
444
|
-
optional: Exclude<Params["optional"], keyof M>;
|
|
445
|
-
defaulted: Exclude<Params["defaulted"], keyof M>;
|
|
446
|
-
extra: Params["extra"];
|
|
447
|
-
}>;
|
|
448
|
-
partial(): ZodInterfacePartial<this>;
|
|
449
|
-
partial<M extends util.Mask<string & keyof Shape>>(mask: M): ZodInterfacePartial<this, string & keyof M>;
|
|
450
|
-
required(): ZodInterfaceRequired<this, string & keyof Shape>;
|
|
451
|
-
required<M extends util.Mask<string & keyof Shape>>(mask: M): ZodInterfaceRequired<this, string & keyof M>;
|
|
452
|
-
}
|
|
453
|
-
export declare const ZodInterface: core.$constructor<ZodInterface>;
|
|
454
|
-
declare function _interface<T extends core.$ZodLooseShape>(shape: T, params?: string | core.$ZodInterfaceParams, Class?: util.Constructor<ZodInterface>): ZodInterface<util.CleanInterfaceShape<T>, util.InitInterfaceParams<T, {}>>;
|
|
455
|
-
export { _interface as interface };
|
|
456
|
-
export declare function strictInterface<T extends core.$ZodLooseShape>(shape: T, params?: string | core.$ZodInterfaceParams): ZodInterface<util.CleanInterfaceShape<T>, util.InitInterfaceParams<T, {}>>;
|
|
457
|
-
export declare function looseInterface<T extends core.$ZodLooseShape>(shape: T, params?: string | core.$ZodInterfaceParams): ZodInterface<util.CleanInterfaceShape<T>, util.InitInterfaceParams<T, Record<string, unknown>>>;
|
|
458
|
-
export interface ZodObject<out Shape extends core.$ZodShape = core.$ZodShape, Extra extends Record<string, unknown> = Record<string, unknown>> extends ZodType {
|
|
459
|
-
_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>;
|
|
460
391
|
shape: Shape;
|
|
461
392
|
keyof(): ZodEnum<util.ToEnum<keyof Shape & string>>;
|
|
393
|
+
/** Define a schema to validate all unrecognized keys. This overrides the existing strict/loose behavior. */
|
|
462
394
|
catchall<T extends core.$ZodType>(schema: T): ZodObject<Shape, Record<string, T["_zod"]["output"]>>;
|
|
463
395
|
/** @deprecated Use `z.looseObject()` or `.loose()` instead. */
|
|
464
396
|
passthrough(): ZodObject<Shape, Record<string, unknown>>;
|
|
397
|
+
/** Consider `z.looseObject(A.shape)` instead */
|
|
465
398
|
loose(): ZodObject<Shape, Record<string, unknown>>;
|
|
466
|
-
/**
|
|
399
|
+
/** Consider `z.strictObject(A.shape)` instead */
|
|
467
400
|
strict(): ZodObject<Shape, {}>;
|
|
468
|
-
/**
|
|
401
|
+
/** This is the default behavior. This method call is likely unnecessary. */
|
|
469
402
|
strip(): ZodObject<Shape, {}>;
|
|
470
|
-
extend<
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
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>;
|
|
476
427
|
partial(): ZodObject<{
|
|
477
428
|
[k in keyof Shape]: ZodOptional<Shape[k]>;
|
|
478
|
-
},
|
|
429
|
+
}, OutExtra, InExtra>;
|
|
479
430
|
partial<M extends util.Exactly<util.Mask<string & keyof Shape>, M>>(mask: M): ZodObject<{
|
|
480
431
|
[k in keyof Shape]: k extends keyof M ? ZodOptional<Shape[k]> : Shape[k];
|
|
481
|
-
},
|
|
432
|
+
}, OutExtra, InExtra>;
|
|
482
433
|
required(): ZodObject<{
|
|
483
434
|
[k in keyof Shape]: ZodNonOptional<Shape[k]>;
|
|
484
|
-
},
|
|
435
|
+
}, OutExtra, InExtra>;
|
|
485
436
|
required<M extends util.Exactly<util.Mask<string & keyof Shape>, M>>(mask: M): ZodObject<{
|
|
486
437
|
[k in keyof Shape]: k extends keyof M ? ZodNonOptional<Shape[k]> : Shape[k];
|
|
487
|
-
},
|
|
438
|
+
}, OutExtra, InExtra>;
|
|
488
439
|
}
|
|
489
440
|
export declare const ZodObject: core.$constructor<ZodObject>;
|
|
490
|
-
export declare function object<T extends core.$
|
|
491
|
-
export declare function strictObject<T extends core.$
|
|
492
|
-
export declare function looseObject<T extends core.$
|
|
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, {
|
|
493
444
|
[k: string]: unknown;
|
|
494
|
-
}>;
|
|
495
|
-
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>>;
|
|
496
|
-
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"]>;
|
|
497
|
-
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"]>;
|
|
498
|
-
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"]>, {
|
|
499
|
-
extra: T["_zod"]["extra"] & U["_zod"]["extra"];
|
|
500
|
-
optional: Exclude<T["_zod"]["optional"], keyof U["_zod"]["def"]["shape"]> | U["_zod"]["optional"];
|
|
501
|
-
defaulted: Exclude<T["_zod"]["defaulted"], keyof U["_zod"]["def"]["shape"]> | U["_zod"]["defaulted"];
|
|
502
|
-
}> : ZodObject<util.Extend<T["_zod"]["def"]["shape"], U>, T["_zod"]["extra"]>;
|
|
503
|
-
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>>, {
|
|
504
|
-
optional: Extract<T["_zod"]["optional"], keyof M>;
|
|
505
|
-
defaulted: Extract<T["_zod"]["defaulted"], keyof M>;
|
|
506
|
-
extra: T["_zod"]["extra"];
|
|
507
|
-
}> : ZodObject<util.Flatten<Pick<T["_zod"]["def"]["shape"], keyof T["_zod"]["def"]["shape"] & keyof M>>, T["_zod"]["extra"]>;
|
|
508
|
-
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>>, {
|
|
509
|
-
optional: Exclude<T["_zod"]["optional"], keyof M>;
|
|
510
|
-
defaulted: Exclude<T["_zod"]["defaulted"], keyof M>;
|
|
511
|
-
extra: T["_zod"]["extra"];
|
|
512
|
-
}> : ZodObject<util.Flatten<Omit<T["_zod"]["def"]["shape"], keyof M>>, T["_zod"]["extra"]>;
|
|
513
|
-
export declare function partial<T extends ZodObjectLike>(schema: T): T["_zod"]["def"]["type"] extends "interface" ? ZodInterface<{
|
|
514
|
-
[k in keyof T["_zod"]["def"]["shape"]]: ZodOptional<T["_zod"]["def"]["shape"][k]>;
|
|
515
445
|
}, {
|
|
516
|
-
|
|
517
|
-
defaulted: never;
|
|
518
|
-
extra: T["_zod"]["extra"];
|
|
519
|
-
}> : ZodObject<{
|
|
520
|
-
[k in keyof T["_zod"]["def"]["shape"]]: ZodOptional<T["_zod"]["def"]["shape"][k]>;
|
|
521
|
-
}, T["_zod"]["extra"]>;
|
|
522
|
-
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"], {
|
|
523
|
-
[k in keyof M & keyof T["_zod"]["def"]["shape"]]: ZodOptional<T["_zod"]["def"]["shape"][k]>;
|
|
524
|
-
}>, {
|
|
525
|
-
optional: string & (T["_zod"]["optional"] | keyof M);
|
|
526
|
-
defaulted: T["_zod"]["defaulted"];
|
|
527
|
-
extra: T["_zod"]["extra"];
|
|
528
|
-
}> : ZodObject<{
|
|
529
|
-
[k in keyof T["_zod"]["def"]["shape"]]: k extends keyof M ? ZodOptional<T["_zod"]["def"]["shape"][k]> : T["_zod"]["def"]["shape"][k];
|
|
530
|
-
}, T["_zod"]["extra"]>;
|
|
531
|
-
export declare function required<T extends {
|
|
532
|
-
_subtype: "object";
|
|
533
|
-
} & ZodObject>(schema: T): ZodObject<{
|
|
534
|
-
[k in keyof T["_zod"]["def"]["shape"]]: ZodNonOptional<T["_zod"]["def"]["shape"][k]>;
|
|
535
|
-
}>;
|
|
536
|
-
export declare function required<T extends {
|
|
537
|
-
_subtype: "object";
|
|
538
|
-
} & ZodObject, M extends util.Exactly<util.Mask<keyof T["_zod"]["def"]["shape"]>, M>>(schema: T, mask: M): ZodObject<util.Extend<T["_zod"]["def"]["shape"], {
|
|
539
|
-
[k in keyof M & keyof T["_zod"]["def"]["shape"]]: ZodNonOptional<T["_zod"]["def"]["shape"][k]>;
|
|
540
|
-
}>>;
|
|
541
|
-
export declare function required<T extends {
|
|
542
|
-
_subtype: "interface";
|
|
543
|
-
} & ZodInterface>(schema: T): ZodInterface<{
|
|
544
|
-
[k in keyof T["_zod"]["def"]["shape"]]: ZodNonOptional<T["_zod"]["def"]["shape"][k]>;
|
|
545
|
-
}, {
|
|
546
|
-
optional: never;
|
|
547
|
-
defaulted: T["_zod"]["defaulted"];
|
|
548
|
-
extra: T["_zod"]["extra"];
|
|
549
|
-
}>;
|
|
550
|
-
export declare function required<T extends {
|
|
551
|
-
_subtype: "interface";
|
|
552
|
-
} & ZodInterface, M extends util.Mask<keyof T["_zod"]["output"]>>(schema: T, mask: M): ZodInterface<util.Extend<T["_zod"]["def"]["shape"], {
|
|
553
|
-
[k in keyof M & keyof T["_zod"]["def"]["shape"]]: ZodNonOptional<T["_zod"]["def"]["shape"][k]>;
|
|
554
|
-
}>, {
|
|
555
|
-
optional: Exclude<T["_zod"]["optional"], keyof M>;
|
|
556
|
-
defaulted: T["_zod"]["defaulted"];
|
|
557
|
-
extra: T["_zod"]["extra"];
|
|
446
|
+
[k: string]: unknown;
|
|
558
447
|
}>;
|
|
448
|
+
export declare function partial<T>(shape: T): Partial<T>;
|
|
559
449
|
export interface ZodUnion<T extends readonly core.$ZodType[] = readonly core.$ZodType[]> extends ZodType {
|
|
560
450
|
_zod: core.$ZodUnionInternals<T>;
|
|
561
451
|
options: T;
|
package/dist/commonjs/schemas.js
CHANGED
|
@@ -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.
|
|
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 =
|
|
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,10 @@ 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
74
|
exports.partial = partial;
|
|
82
|
-
exports.required = required;
|
|
83
75
|
exports.union = union;
|
|
84
76
|
exports.discriminatedUnion = discriminatedUnion;
|
|
85
77
|
exports.intersection = intersection;
|
|
@@ -576,95 +568,17 @@ exports.ZodArray = core.$constructor("ZodArray", (inst, def) => {
|
|
|
576
568
|
function array(element, params) {
|
|
577
569
|
return core._array(exports.ZodArray, element, params);
|
|
578
570
|
}
|
|
579
|
-
|
|
580
|
-
core.$ZodObjectLike.init(inst, def);
|
|
581
|
-
exports.ZodType.init(inst, def);
|
|
582
|
-
});
|
|
571
|
+
// .keyof
|
|
583
572
|
function keyof(schema) {
|
|
584
|
-
const shape = schema._zod.def.
|
|
585
|
-
? core_1.util.cleanInterfaceShape(schema._zod.def.shape).shape
|
|
586
|
-
: schema._zod.def.shape;
|
|
573
|
+
const shape = schema._zod.def.shape;
|
|
587
574
|
return literal(Object.keys(shape));
|
|
588
575
|
}
|
|
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
576
|
exports.ZodObject = core.$constructor("ZodObject", (inst, def) => {
|
|
665
577
|
core.$ZodObject.init(inst, def);
|
|
666
578
|
exports.ZodType.init(inst, def);
|
|
667
|
-
inst
|
|
579
|
+
core_1.util.defineLazy(inst, "shape", () => {
|
|
580
|
+
return Object.fromEntries(Object.entries(inst._zod.def.shape));
|
|
581
|
+
});
|
|
668
582
|
inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
|
|
669
583
|
inst.catchall = (catchall) => inst.clone({ ...inst._zod.def, catchall });
|
|
670
584
|
inst.passthrough = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
|
|
@@ -673,22 +587,20 @@ exports.ZodObject = core.$constructor("ZodObject", (inst, def) => {
|
|
|
673
587
|
inst.strict = () => inst.clone({ ...inst._zod.def, catchall: never() });
|
|
674
588
|
inst.strip = () => inst.clone({ ...inst._zod.def, catchall: undefined });
|
|
675
589
|
inst.extend = (incoming) => {
|
|
676
|
-
|
|
677
|
-
return core_1.util.extendObjectLike(inst, incoming);
|
|
678
|
-
return core_1.util.extendObjectLike(inst, object(incoming));
|
|
590
|
+
return core_1.util.extend(inst, incoming);
|
|
679
591
|
};
|
|
680
|
-
inst.merge = (other) => core_1.util.
|
|
592
|
+
inst.merge = (other) => core_1.util.merge(inst, other);
|
|
681
593
|
inst.pick = (mask) => core_1.util.pick(inst, mask);
|
|
682
594
|
inst.omit = (mask) => core_1.util.omit(inst, mask);
|
|
683
|
-
inst.partial = (...args) => core_1.util.
|
|
684
|
-
inst.required = (...args) => core_1.util.
|
|
595
|
+
inst.partial = (...args) => core_1.util.partial(exports.ZodOptional, inst, args[0]);
|
|
596
|
+
inst.required = (...args) => core_1.util.required(exports.ZodNonOptional, inst, args[0]);
|
|
685
597
|
});
|
|
686
598
|
function object(shape, params) {
|
|
687
599
|
const def = {
|
|
688
600
|
type: "object",
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
return
|
|
601
|
+
get shape() {
|
|
602
|
+
core_1.util.assignProp(this, "shape", { ...shape });
|
|
603
|
+
return this.shape;
|
|
692
604
|
},
|
|
693
605
|
...core_1.util.normalizeParams(params),
|
|
694
606
|
};
|
|
@@ -698,9 +610,9 @@ function object(shape, params) {
|
|
|
698
610
|
function strictObject(shape, params) {
|
|
699
611
|
return new exports.ZodObject({
|
|
700
612
|
type: "object",
|
|
701
|
-
shape
|
|
702
|
-
|
|
703
|
-
return
|
|
613
|
+
get shape() {
|
|
614
|
+
core_1.util.assignProp(this, "shape", { ...shape });
|
|
615
|
+
return this.shape;
|
|
704
616
|
},
|
|
705
617
|
catchall: never(),
|
|
706
618
|
...core_1.util.normalizeParams(params),
|
|
@@ -710,39 +622,16 @@ function strictObject(shape, params) {
|
|
|
710
622
|
function looseObject(shape, params) {
|
|
711
623
|
return new exports.ZodObject({
|
|
712
624
|
type: "object",
|
|
713
|
-
shape
|
|
714
|
-
|
|
715
|
-
return
|
|
625
|
+
get shape() {
|
|
626
|
+
core_1.util.assignProp(this, "shape", { ...shape });
|
|
627
|
+
return this.shape;
|
|
716
628
|
},
|
|
717
629
|
catchall: unknown(),
|
|
718
630
|
...core_1.util.normalizeParams(params),
|
|
719
631
|
});
|
|
720
632
|
}
|
|
721
|
-
function
|
|
722
|
-
|
|
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);
|
|
633
|
+
function partial(shape) {
|
|
634
|
+
return shape;
|
|
746
635
|
}
|
|
747
636
|
exports.ZodUnion = core.$constructor("ZodUnion", (inst, def) => {
|
|
748
637
|
core.$ZodUnion.init(inst, def);
|