zod 3.13.2 → 3.14.0
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 +35 -29
- package/lib/ZodError.js +110 -205
- package/lib/benchmarks/discriminatedUnion.js +25 -25
- package/lib/benchmarks/index.js +13 -53
- package/lib/benchmarks/object.js +23 -23
- package/lib/benchmarks/realworld.d.ts +5 -0
- package/lib/benchmarks/realworld.js +56 -0
- package/lib/benchmarks/string.js +16 -16
- package/lib/benchmarks/union.js +25 -25
- package/lib/external.js +5 -1
- package/lib/helpers/errorUtil.js +2 -6
- package/lib/helpers/parseUtil.d.ts +1 -2
- package/lib/helpers/parseUtil.js +82 -242
- package/lib/helpers/util.js +20 -66
- package/lib/index.js +6 -2
- package/lib/index.mjs +1530 -2097
- package/lib/types.d.ts +4 -2
- package/lib/types.js +1319 -1704
- package/package.json +3 -3
package/lib/types.d.ts
CHANGED
|
@@ -465,7 +465,8 @@ export interface ZodRecordDef<Key extends KeySchema = ZodString, Value extends Z
|
|
|
465
465
|
typeName: ZodFirstPartyTypeKind.ZodRecord;
|
|
466
466
|
}
|
|
467
467
|
declare type KeySchema = ZodType<string | number | symbol, any, any>;
|
|
468
|
-
|
|
468
|
+
declare type RecordType<K extends string | number | symbol, V> = [string] extends [K] ? Record<K, V> : [number] extends [K] ? Record<K, V> : [symbol] extends [K] ? Record<K, V> : Partial<Record<K, V>>;
|
|
469
|
+
export declare class ZodRecord<Key extends KeySchema = ZodString, Value extends ZodTypeAny = ZodTypeAny> extends ZodType<RecordType<Key["_output"], Value["_output"]>, ZodRecordDef<Key, Value>, RecordType<Key["_input"], Value["_input"]>> {
|
|
469
470
|
get keySchema(): Key;
|
|
470
471
|
get valueSchema(): Value;
|
|
471
472
|
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
|
|
@@ -571,6 +572,7 @@ declare type EnumLike = {
|
|
|
571
572
|
};
|
|
572
573
|
export declare class ZodNativeEnum<T extends EnumLike> extends ZodType<T[keyof T], ZodNativeEnumDef<T>> {
|
|
573
574
|
_parse(input: ParseInput): ParseReturnType<T[keyof T]>;
|
|
575
|
+
get enum(): T;
|
|
574
576
|
static create: <T_1 extends EnumLike>(values: T_1, params?: RawCreateParams) => ZodNativeEnum<T_1>;
|
|
575
577
|
}
|
|
576
578
|
export interface ZodPromiseDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
|
|
@@ -683,7 +685,7 @@ export declare enum ZodFirstPartyTypeKind {
|
|
|
683
685
|
ZodDefault = "ZodDefault",
|
|
684
686
|
ZodPromise = "ZodPromise"
|
|
685
687
|
}
|
|
686
|
-
export declare type ZodFirstPartySchemaTypes = ZodString | ZodNumber | ZodNaN | ZodBigInt | ZodBoolean | ZodDate | ZodUndefined | ZodNull | ZodAny | ZodUnknown | ZodNever | ZodVoid | ZodArray<any, any> | ZodObject<any, any, any, any, any> | ZodUnion<any> | ZodIntersection<any, any> | ZodTuple<any, any> | ZodRecord<any, any> | ZodMap<any> | ZodSet<any> | ZodFunction<any, any> | ZodLazy<any> | ZodLiteral<any> | ZodEnum<any> | ZodEffects<any, any, any> | ZodNativeEnum<any> | ZodOptional<any> | ZodNullable<any> | ZodDefault<any> | ZodPromise<any>;
|
|
688
|
+
export declare type ZodFirstPartySchemaTypes = ZodString | ZodNumber | ZodNaN | ZodBigInt | ZodBoolean | ZodDate | ZodUndefined | ZodNull | ZodAny | ZodUnknown | ZodNever | ZodVoid | ZodArray<any, any> | ZodObject<any, any, any, any, any> | ZodUnion<any> | ZodDiscriminatedUnion<any, any, any> | ZodIntersection<any, any> | ZodTuple<any, any> | ZodRecord<any, any> | ZodMap<any> | ZodSet<any> | ZodFunction<any, any> | ZodLazy<any> | ZodLiteral<any> | ZodEnum<any> | ZodEffects<any, any, any> | ZodNativeEnum<any> | ZodOptional<any> | ZodNullable<any> | ZodDefault<any> | ZodPromise<any>;
|
|
687
689
|
declare const instanceOfType: <T extends new (...args: any[]) => any>(cls: T, params?: Parameters<ZodTypeAny["refine"]>[1]) => ZodType<InstanceType<T>, ZodTypeDef, InstanceType<T>>;
|
|
688
690
|
declare const stringType: (params?: RawCreateParams) => ZodString;
|
|
689
691
|
declare const numberType: (params?: RawCreateParams) => ZodNumber;
|