zod 3.25.12-alpha.0 → 3.25.13
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 +16 -17
- package/dist/types/index.d.ts +0 -3
- package/dist/types/index.js +0 -3
- package/dist/types/v3/ZodError.d.ts +0 -164
- package/dist/types/v3/ZodError.js +0 -132
- package/dist/types/v3/benchmarks/datetime.d.ts +0 -5
- package/dist/types/v3/benchmarks/datetime.js +0 -49
- package/dist/types/v3/benchmarks/discriminatedUnion.d.ts +0 -5
- package/dist/types/v3/benchmarks/discriminatedUnion.js +0 -74
- package/dist/types/v3/benchmarks/index.d.ts +0 -1
- package/dist/types/v3/benchmarks/index.js +0 -54
- package/dist/types/v3/benchmarks/ipv4.d.ts +0 -5
- package/dist/types/v3/benchmarks/ipv4.js +0 -49
- package/dist/types/v3/benchmarks/object.d.ts +0 -5
- package/dist/types/v3/benchmarks/object.js +0 -65
- package/dist/types/v3/benchmarks/primitives.d.ts +0 -5
- package/dist/types/v3/benchmarks/primitives.js +0 -154
- package/dist/types/v3/benchmarks/realworld.d.ts +0 -5
- package/dist/types/v3/benchmarks/realworld.js +0 -51
- package/dist/types/v3/benchmarks/string.d.ts +0 -5
- package/dist/types/v3/benchmarks/string.js +0 -50
- package/dist/types/v3/benchmarks/union.d.ts +0 -5
- package/dist/types/v3/benchmarks/union.js +0 -74
- package/dist/types/v3/errors.d.ts +0 -5
- package/dist/types/v3/errors.js +0 -9
- package/dist/types/v3/external.d.ts +0 -6
- package/dist/types/v3/external.js +0 -6
- package/dist/types/v3/helpers/enumUtil.d.ts +0 -8
- package/dist/types/v3/helpers/enumUtil.js +0 -1
- package/dist/types/v3/helpers/errorUtil.d.ts +0 -9
- package/dist/types/v3/helpers/errorUtil.js +0 -6
- package/dist/types/v3/helpers/parseUtil.d.ts +0 -78
- package/dist/types/v3/helpers/parseUtil.js +0 -109
- package/dist/types/v3/helpers/partialUtil.d.ts +0 -8
- package/dist/types/v3/helpers/partialUtil.js +0 -1
- package/dist/types/v3/helpers/typeAliases.d.ts +0 -2
- package/dist/types/v3/helpers/typeAliases.js +0 -1
- package/dist/types/v3/helpers/util.d.ts +0 -85
- package/dist/types/v3/helpers/util.js +0 -133
- package/dist/types/v3/index.d.ts +0 -4
- package/dist/types/v3/index.js +0 -4
- package/dist/types/v3/locales/en.d.ts +0 -3
- package/dist/types/v3/locales/en.js +0 -107
- package/dist/types/v3/standard-schema.d.ts +0 -102
- package/dist/types/v3/standard-schema.js +0 -1
- package/dist/types/v3/tests/Mocker.d.ts +0 -17
- package/dist/types/v3/tests/Mocker.js +0 -53
- package/dist/types/v3/tests/language-server.source.d.ts +0 -70
- package/dist/types/v3/tests/language-server.source.js +0 -45
- package/dist/types/v3/types.d.ts +0 -1031
- package/dist/types/v3/types.js +0 -3713
- package/dist/types/v4/classic/checks.d.ts +0 -1
- package/dist/types/v4/classic/checks.js +0 -1
- package/dist/types/v4/classic/coerce.d.ts +0 -17
- package/dist/types/v4/classic/coerce.js +0 -17
- package/dist/types/v4/classic/compat.d.ts +0 -48
- package/dist/types/v4/classic/compat.js +0 -33
- package/dist/types/v4/classic/errors.d.ts +0 -30
- package/dist/types/v4/classic/errors.js +0 -41
- package/dist/types/v4/classic/external.d.ts +0 -8
- package/dist/types/v4/classic/external.js +0 -11
- package/dist/types/v4/classic/index.d.ts +0 -4
- package/dist/types/v4/classic/index.js +0 -4
- package/dist/types/v4/classic/iso.d.ts +0 -22
- package/dist/types/v4/classic/iso.js +0 -30
- package/dist/types/v4/classic/parse.d.ts +0 -23
- package/dist/types/v4/classic/parse.js +0 -6
- package/dist/types/v4/classic/schemas.d.ts +0 -653
- package/dist/types/v4/classic/schemas.js +0 -1012
- package/dist/types/v4/core/api.d.ts +0 -273
- package/dist/types/v4/core/api.js +0 -867
- package/dist/types/v4/core/checks.d.ts +0 -277
- package/dist/types/v4/core/checks.js +0 -535
- package/dist/types/v4/core/config.d.ts +0 -9
- package/dist/types/v4/core/config.js +0 -6
- package/dist/types/v4/core/core.d.ts +0 -43
- package/dist/types/v4/core/core.js +0 -53
- package/dist/types/v4/core/doc.d.ts +0 -14
- package/dist/types/v4/core/doc.js +0 -36
- package/dist/types/v4/core/errors.d.ts +0 -204
- package/dist/types/v4/core/errors.js +0 -206
- package/dist/types/v4/core/function.d.ts +0 -35
- package/dist/types/v4/core/function.js +0 -70
- package/dist/types/v4/core/index.d.ts +0 -15
- package/dist/types/v4/core/index.js +0 -15
- package/dist/types/v4/core/json-schema.d.ts +0 -100
- package/dist/types/v4/core/json-schema.js +0 -1
- package/dist/types/v4/core/parse.d.ts +0 -25
- package/dist/types/v4/core/parse.js +0 -57
- package/dist/types/v4/core/regexes.d.ts +0 -62
- package/dist/types/v4/core/regexes.js +0 -93
- package/dist/types/v4/core/registries.d.ts +0 -32
- package/dist/types/v4/core/registries.js +0 -42
- package/dist/types/v4/core/schemas.d.ts +0 -975
- package/dist/types/v4/core/schemas.js +0 -1740
- package/dist/types/v4/core/standard-schema.d.ts +0 -55
- package/dist/types/v4/core/standard-schema.js +0 -1
- package/dist/types/v4/core/to-json-schema.d.ts +0 -84
- package/dist/types/v4/core/to-json-schema.js +0 -665
- package/dist/types/v4/core/util.d.ts +0 -186
- package/dist/types/v4/core/util.js +0 -469
- package/dist/types/v4/core/versions.d.ts +0 -5
- package/dist/types/v4/core/versions.js +0 -5
- package/dist/types/v4/core/zsf.d.ts +0 -91
- package/dist/types/v4/core/zsf.js +0 -171
- package/dist/types/v4/index.d.ts +0 -3
- package/dist/types/v4/index.js +0 -3
- package/dist/types/v4/locales/ar.d.ts +0 -7
- package/dist/types/v4/locales/ar.js +0 -115
- package/dist/types/v4/locales/az.d.ts +0 -7
- package/dist/types/v4/locales/az.js +0 -114
- package/dist/types/v4/locales/be.d.ts +0 -7
- package/dist/types/v4/locales/be.js +0 -163
- package/dist/types/v4/locales/ca.d.ts +0 -7
- package/dist/types/v4/locales/ca.js +0 -117
- package/dist/types/v4/locales/cs.d.ts +0 -7
- package/dist/types/v4/locales/cs.js +0 -134
- package/dist/types/v4/locales/de.d.ts +0 -7
- package/dist/types/v4/locales/de.js +0 -115
- package/dist/types/v4/locales/en.d.ts +0 -7
- package/dist/types/v4/locales/en.js +0 -117
- package/dist/types/v4/locales/es.d.ts +0 -7
- package/dist/types/v4/locales/es.js +0 -116
- package/dist/types/v4/locales/fa.d.ts +0 -7
- package/dist/types/v4/locales/fa.js +0 -121
- package/dist/types/v4/locales/fi.d.ts +0 -7
- package/dist/types/v4/locales/fi.js +0 -121
- package/dist/types/v4/locales/fr.d.ts +0 -7
- package/dist/types/v4/locales/fr.js +0 -115
- package/dist/types/v4/locales/frCA.d.ts +0 -7
- package/dist/types/v4/locales/frCA.js +0 -116
- package/dist/types/v4/locales/he.d.ts +0 -7
- package/dist/types/v4/locales/he.js +0 -116
- package/dist/types/v4/locales/hu.d.ts +0 -7
- package/dist/types/v4/locales/hu.js +0 -116
- package/dist/types/v4/locales/id.d.ts +0 -7
- package/dist/types/v4/locales/id.js +0 -115
- package/dist/types/v4/locales/index.d.ts +0 -34
- package/dist/types/v4/locales/index.js +0 -34
- package/dist/types/v4/locales/it.d.ts +0 -7
- package/dist/types/v4/locales/it.js +0 -116
- package/dist/types/v4/locales/ja.d.ts +0 -7
- package/dist/types/v4/locales/ja.js +0 -114
- package/dist/types/v4/locales/ko.d.ts +0 -7
- package/dist/types/v4/locales/ko.js +0 -120
- package/dist/types/v4/locales/mk.d.ts +0 -7
- package/dist/types/v4/locales/mk.js +0 -117
- package/dist/types/v4/locales/ms.d.ts +0 -7
- package/dist/types/v4/locales/ms.js +0 -115
- package/dist/types/v4/locales/no.d.ts +0 -7
- package/dist/types/v4/locales/no.js +0 -115
- package/dist/types/v4/locales/ota.d.ts +0 -7
- package/dist/types/v4/locales/ota.js +0 -116
- package/dist/types/v4/locales/pl.d.ts +0 -7
- package/dist/types/v4/locales/pl.js +0 -116
- package/dist/types/v4/locales/pt.d.ts +0 -7
- package/dist/types/v4/locales/pt.js +0 -115
- package/dist/types/v4/locales/ru.d.ts +0 -7
- package/dist/types/v4/locales/ru.js +0 -163
- package/dist/types/v4/locales/sl.d.ts +0 -7
- package/dist/types/v4/locales/sl.js +0 -116
- package/dist/types/v4/locales/ta.d.ts +0 -7
- package/dist/types/v4/locales/ta.js +0 -116
- package/dist/types/v4/locales/th.d.ts +0 -7
- package/dist/types/v4/locales/th.js +0 -116
- package/dist/types/v4/locales/tr.d.ts +0 -7
- package/dist/types/v4/locales/tr.js +0 -114
- package/dist/types/v4/locales/ua.d.ts +0 -7
- package/dist/types/v4/locales/ua.js +0 -116
- package/dist/types/v4/locales/ur.d.ts +0 -7
- package/dist/types/v4/locales/ur.js +0 -116
- package/dist/types/v4/locales/vi.d.ts +0 -7
- package/dist/types/v4/locales/vi.js +0 -115
- package/dist/types/v4/locales/zh-CN.d.ts +0 -7
- package/dist/types/v4/locales/zh-CN.js +0 -115
- package/dist/types/v4/locales/zh-tw.d.ts +0 -7
- package/dist/types/v4/locales/zh-tw.js +0 -116
- package/dist/types/v4/mini/checks.d.ts +0 -1
- package/dist/types/v4/mini/checks.js +0 -1
- package/dist/types/v4/mini/coerce.d.ts +0 -7
- package/dist/types/v4/mini/coerce.js +0 -17
- package/dist/types/v4/mini/external.d.ts +0 -7
- package/dist/types/v4/mini/external.js +0 -7
- package/dist/types/v4/mini/index.d.ts +0 -3
- package/dist/types/v4/mini/index.js +0 -3
- package/dist/types/v4/mini/iso.d.ts +0 -22
- package/dist/types/v4/mini/iso.js +0 -30
- package/dist/types/v4/mini/parse.d.ts +0 -1
- package/dist/types/v4/mini/parse.js +0 -1
- package/dist/types/v4/mini/schemas.d.ts +0 -405
- package/dist/types/v4/mini/schemas.js +0 -738
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { ZodArray, ZodNullable, ZodObject, ZodOptional, ZodRawShape, ZodTuple, ZodTupleItems, ZodTypeAny } from "../types.js";
|
|
2
|
-
export declare namespace partialUtil {
|
|
3
|
-
type DeepPartial<T extends ZodTypeAny> = T extends ZodObject<ZodRawShape> ? ZodObject<{
|
|
4
|
-
[k in keyof T["shape"]]: ZodOptional<DeepPartial<T["shape"][k]>>;
|
|
5
|
-
}, T["_def"]["unknownKeys"], T["_def"]["catchall"]> : T extends ZodArray<infer Type, infer Card> ? ZodArray<DeepPartial<Type>, Card> : T extends ZodOptional<infer Type> ? ZodOptional<DeepPartial<Type>> : T extends ZodNullable<infer Type> ? ZodNullable<DeepPartial<Type>> : T extends ZodTuple<infer Items> ? {
|
|
6
|
-
[k in keyof Items]: Items[k] extends ZodTypeAny ? DeepPartial<Items[k]> : never;
|
|
7
|
-
} extends infer PI ? PI extends ZodTupleItems ? ZodTuple<PI> : never : never : T;
|
|
8
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
export declare namespace util {
|
|
2
|
-
type AssertEqual<T, U> = (<V>() => V extends T ? 1 : 2) extends <V>() => V extends U ? 1 : 2 ? true : false;
|
|
3
|
-
export type isAny<T> = 0 extends 1 & T ? true : false;
|
|
4
|
-
export const assertEqual: <A, B>(_: AssertEqual<A, B>) => void;
|
|
5
|
-
export function assertIs<T>(_arg: T): void;
|
|
6
|
-
export function assertNever(_x: never): never;
|
|
7
|
-
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
|
8
|
-
export type OmitKeys<T, K extends string> = Pick<T, Exclude<keyof T, K>>;
|
|
9
|
-
export type MakePartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
10
|
-
export type Exactly<T, X> = T & Record<Exclude<keyof X, keyof T>, never>;
|
|
11
|
-
export type InexactPartial<T> = {
|
|
12
|
-
[k in keyof T]?: T[k] | undefined;
|
|
13
|
-
};
|
|
14
|
-
export const arrayToEnum: <T extends string, U extends [T, ...T[]]>(items: U) => { [k in U[number]]: k; };
|
|
15
|
-
export const getValidEnumValues: (obj: any) => any[];
|
|
16
|
-
export const objectValues: (obj: any) => any[];
|
|
17
|
-
export const objectKeys: ObjectConstructor["keys"];
|
|
18
|
-
export const find: <T>(arr: T[], checker: (arg: T) => any) => T | undefined;
|
|
19
|
-
export type identity<T> = objectUtil.identity<T>;
|
|
20
|
-
export type flatten<T> = objectUtil.flatten<T>;
|
|
21
|
-
export type noUndefined<T> = T extends undefined ? never : T;
|
|
22
|
-
export const isInteger: NumberConstructor["isInteger"];
|
|
23
|
-
export function joinValues<T extends any[]>(array: T, separator?: string): string;
|
|
24
|
-
export const jsonStringifyReplacer: (_: string, value: any) => any;
|
|
25
|
-
export {};
|
|
26
|
-
}
|
|
27
|
-
export declare namespace objectUtil {
|
|
28
|
-
export type MergeShapes<U, V> = keyof U & keyof V extends never ? U & V : {
|
|
29
|
-
[k in Exclude<keyof U, keyof V>]: U[k];
|
|
30
|
-
} & V;
|
|
31
|
-
type optionalKeys<T extends object> = {
|
|
32
|
-
[k in keyof T]: undefined extends T[k] ? k : never;
|
|
33
|
-
}[keyof T];
|
|
34
|
-
type requiredKeys<T extends object> = {
|
|
35
|
-
[k in keyof T]: undefined extends T[k] ? never : k;
|
|
36
|
-
}[keyof T];
|
|
37
|
-
export type addQuestionMarks<T extends object, _O = any> = {
|
|
38
|
-
[K in requiredKeys<T>]: T[K];
|
|
39
|
-
} & {
|
|
40
|
-
[K in optionalKeys<T>]?: T[K];
|
|
41
|
-
} & {
|
|
42
|
-
[k in keyof T]?: unknown;
|
|
43
|
-
};
|
|
44
|
-
export type identity<T> = T;
|
|
45
|
-
export type flatten<T> = identity<{
|
|
46
|
-
[k in keyof T]: T[k];
|
|
47
|
-
}>;
|
|
48
|
-
export type noNeverKeys<T> = {
|
|
49
|
-
[k in keyof T]: [T[k]] extends [never] ? never : k;
|
|
50
|
-
}[keyof T];
|
|
51
|
-
export type noNever<T> = identity<{
|
|
52
|
-
[k in noNeverKeys<T>]: k extends keyof T ? T[k] : never;
|
|
53
|
-
}>;
|
|
54
|
-
export const mergeShapes: <U, T>(first: U, second: T) => T & U;
|
|
55
|
-
export type extendShape<A extends object, B extends object> = keyof A & keyof B extends never ? A & B : {
|
|
56
|
-
[K in keyof A as K extends keyof B ? never : K]: A[K];
|
|
57
|
-
} & {
|
|
58
|
-
[K in keyof B]: B[K];
|
|
59
|
-
};
|
|
60
|
-
export {};
|
|
61
|
-
}
|
|
62
|
-
export declare const ZodParsedType: {
|
|
63
|
-
string: "string";
|
|
64
|
-
nan: "nan";
|
|
65
|
-
number: "number";
|
|
66
|
-
integer: "integer";
|
|
67
|
-
float: "float";
|
|
68
|
-
boolean: "boolean";
|
|
69
|
-
date: "date";
|
|
70
|
-
bigint: "bigint";
|
|
71
|
-
symbol: "symbol";
|
|
72
|
-
function: "function";
|
|
73
|
-
undefined: "undefined";
|
|
74
|
-
null: "null";
|
|
75
|
-
array: "array";
|
|
76
|
-
object: "object";
|
|
77
|
-
unknown: "unknown";
|
|
78
|
-
promise: "promise";
|
|
79
|
-
void: "void";
|
|
80
|
-
never: "never";
|
|
81
|
-
map: "map";
|
|
82
|
-
set: "set";
|
|
83
|
-
};
|
|
84
|
-
export type ZodParsedType = keyof typeof ZodParsedType;
|
|
85
|
-
export declare const getParsedType: (data: any) => ZodParsedType;
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
export var util;
|
|
2
|
-
(function (util) {
|
|
3
|
-
util.assertEqual = (_) => { };
|
|
4
|
-
function assertIs(_arg) { }
|
|
5
|
-
util.assertIs = assertIs;
|
|
6
|
-
function assertNever(_x) {
|
|
7
|
-
throw new Error();
|
|
8
|
-
}
|
|
9
|
-
util.assertNever = assertNever;
|
|
10
|
-
util.arrayToEnum = (items) => {
|
|
11
|
-
const obj = {};
|
|
12
|
-
for (const item of items) {
|
|
13
|
-
obj[item] = item;
|
|
14
|
-
}
|
|
15
|
-
return obj;
|
|
16
|
-
};
|
|
17
|
-
util.getValidEnumValues = (obj) => {
|
|
18
|
-
const validKeys = util.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
|
|
19
|
-
const filtered = {};
|
|
20
|
-
for (const k of validKeys) {
|
|
21
|
-
filtered[k] = obj[k];
|
|
22
|
-
}
|
|
23
|
-
return util.objectValues(filtered);
|
|
24
|
-
};
|
|
25
|
-
util.objectValues = (obj) => {
|
|
26
|
-
return util.objectKeys(obj).map(function (e) {
|
|
27
|
-
return obj[e];
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
util.objectKeys = typeof Object.keys === "function" // eslint-disable-line ban/ban
|
|
31
|
-
? (obj) => Object.keys(obj) // eslint-disable-line ban/ban
|
|
32
|
-
: (object) => {
|
|
33
|
-
const keys = [];
|
|
34
|
-
for (const key in object) {
|
|
35
|
-
if (Object.prototype.hasOwnProperty.call(object, key)) {
|
|
36
|
-
keys.push(key);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return keys;
|
|
40
|
-
};
|
|
41
|
-
util.find = (arr, checker) => {
|
|
42
|
-
for (const item of arr) {
|
|
43
|
-
if (checker(item))
|
|
44
|
-
return item;
|
|
45
|
-
}
|
|
46
|
-
return undefined;
|
|
47
|
-
};
|
|
48
|
-
util.isInteger = typeof Number.isInteger === "function"
|
|
49
|
-
? (val) => Number.isInteger(val) // eslint-disable-line ban/ban
|
|
50
|
-
: (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
|
|
51
|
-
function joinValues(array, separator = " | ") {
|
|
52
|
-
return array.map((val) => (typeof val === "string" ? `'${val}'` : val)).join(separator);
|
|
53
|
-
}
|
|
54
|
-
util.joinValues = joinValues;
|
|
55
|
-
util.jsonStringifyReplacer = (_, value) => {
|
|
56
|
-
if (typeof value === "bigint") {
|
|
57
|
-
return value.toString();
|
|
58
|
-
}
|
|
59
|
-
return value;
|
|
60
|
-
};
|
|
61
|
-
})(util || (util = {}));
|
|
62
|
-
export var objectUtil;
|
|
63
|
-
(function (objectUtil) {
|
|
64
|
-
objectUtil.mergeShapes = (first, second) => {
|
|
65
|
-
return {
|
|
66
|
-
...first,
|
|
67
|
-
...second, // second overwrites first
|
|
68
|
-
};
|
|
69
|
-
};
|
|
70
|
-
})(objectUtil || (objectUtil = {}));
|
|
71
|
-
export const ZodParsedType = util.arrayToEnum([
|
|
72
|
-
"string",
|
|
73
|
-
"nan",
|
|
74
|
-
"number",
|
|
75
|
-
"integer",
|
|
76
|
-
"float",
|
|
77
|
-
"boolean",
|
|
78
|
-
"date",
|
|
79
|
-
"bigint",
|
|
80
|
-
"symbol",
|
|
81
|
-
"function",
|
|
82
|
-
"undefined",
|
|
83
|
-
"null",
|
|
84
|
-
"array",
|
|
85
|
-
"object",
|
|
86
|
-
"unknown",
|
|
87
|
-
"promise",
|
|
88
|
-
"void",
|
|
89
|
-
"never",
|
|
90
|
-
"map",
|
|
91
|
-
"set",
|
|
92
|
-
]);
|
|
93
|
-
export const getParsedType = (data) => {
|
|
94
|
-
const t = typeof data;
|
|
95
|
-
switch (t) {
|
|
96
|
-
case "undefined":
|
|
97
|
-
return ZodParsedType.undefined;
|
|
98
|
-
case "string":
|
|
99
|
-
return ZodParsedType.string;
|
|
100
|
-
case "number":
|
|
101
|
-
return Number.isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
|
|
102
|
-
case "boolean":
|
|
103
|
-
return ZodParsedType.boolean;
|
|
104
|
-
case "function":
|
|
105
|
-
return ZodParsedType.function;
|
|
106
|
-
case "bigint":
|
|
107
|
-
return ZodParsedType.bigint;
|
|
108
|
-
case "symbol":
|
|
109
|
-
return ZodParsedType.symbol;
|
|
110
|
-
case "object":
|
|
111
|
-
if (Array.isArray(data)) {
|
|
112
|
-
return ZodParsedType.array;
|
|
113
|
-
}
|
|
114
|
-
if (data === null) {
|
|
115
|
-
return ZodParsedType.null;
|
|
116
|
-
}
|
|
117
|
-
if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
|
|
118
|
-
return ZodParsedType.promise;
|
|
119
|
-
}
|
|
120
|
-
if (typeof Map !== "undefined" && data instanceof Map) {
|
|
121
|
-
return ZodParsedType.map;
|
|
122
|
-
}
|
|
123
|
-
if (typeof Set !== "undefined" && data instanceof Set) {
|
|
124
|
-
return ZodParsedType.set;
|
|
125
|
-
}
|
|
126
|
-
if (typeof Date !== "undefined" && data instanceof Date) {
|
|
127
|
-
return ZodParsedType.date;
|
|
128
|
-
}
|
|
129
|
-
return ZodParsedType.object;
|
|
130
|
-
default:
|
|
131
|
-
return ZodParsedType.unknown;
|
|
132
|
-
}
|
|
133
|
-
};
|
package/dist/types/v3/index.d.ts
DELETED
package/dist/types/v3/index.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { ZodIssueCode } from "../ZodError.js";
|
|
2
|
-
import { util, ZodParsedType } from "../helpers/util.js";
|
|
3
|
-
const errorMap = (issue, _ctx) => {
|
|
4
|
-
let message;
|
|
5
|
-
switch (issue.code) {
|
|
6
|
-
case ZodIssueCode.invalid_type:
|
|
7
|
-
if (issue.received === ZodParsedType.undefined) {
|
|
8
|
-
message = "Required";
|
|
9
|
-
}
|
|
10
|
-
else {
|
|
11
|
-
message = `Expected ${issue.expected}, received ${issue.received}`;
|
|
12
|
-
}
|
|
13
|
-
break;
|
|
14
|
-
case ZodIssueCode.invalid_literal:
|
|
15
|
-
message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`;
|
|
16
|
-
break;
|
|
17
|
-
case ZodIssueCode.unrecognized_keys:
|
|
18
|
-
message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`;
|
|
19
|
-
break;
|
|
20
|
-
case ZodIssueCode.invalid_union:
|
|
21
|
-
message = `Invalid input`;
|
|
22
|
-
break;
|
|
23
|
-
case ZodIssueCode.invalid_union_discriminator:
|
|
24
|
-
message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;
|
|
25
|
-
break;
|
|
26
|
-
case ZodIssueCode.invalid_enum_value:
|
|
27
|
-
message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`;
|
|
28
|
-
break;
|
|
29
|
-
case ZodIssueCode.invalid_arguments:
|
|
30
|
-
message = `Invalid function arguments`;
|
|
31
|
-
break;
|
|
32
|
-
case ZodIssueCode.invalid_return_type:
|
|
33
|
-
message = `Invalid function return type`;
|
|
34
|
-
break;
|
|
35
|
-
case ZodIssueCode.invalid_date:
|
|
36
|
-
message = `Invalid date`;
|
|
37
|
-
break;
|
|
38
|
-
case ZodIssueCode.invalid_string:
|
|
39
|
-
if (typeof issue.validation === "object") {
|
|
40
|
-
if ("includes" in issue.validation) {
|
|
41
|
-
message = `Invalid input: must include "${issue.validation.includes}"`;
|
|
42
|
-
if (typeof issue.validation.position === "number") {
|
|
43
|
-
message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
else if ("startsWith" in issue.validation) {
|
|
47
|
-
message = `Invalid input: must start with "${issue.validation.startsWith}"`;
|
|
48
|
-
}
|
|
49
|
-
else if ("endsWith" in issue.validation) {
|
|
50
|
-
message = `Invalid input: must end with "${issue.validation.endsWith}"`;
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
util.assertNever(issue.validation);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
else if (issue.validation !== "regex") {
|
|
57
|
-
message = `Invalid ${issue.validation}`;
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
message = "Invalid";
|
|
61
|
-
}
|
|
62
|
-
break;
|
|
63
|
-
case ZodIssueCode.too_small:
|
|
64
|
-
if (issue.type === "array")
|
|
65
|
-
message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
|
|
66
|
-
else if (issue.type === "string")
|
|
67
|
-
message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
|
|
68
|
-
else if (issue.type === "number")
|
|
69
|
-
message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
|
|
70
|
-
else if (issue.type === "date")
|
|
71
|
-
message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
|
|
72
|
-
else
|
|
73
|
-
message = "Invalid input";
|
|
74
|
-
break;
|
|
75
|
-
case ZodIssueCode.too_big:
|
|
76
|
-
if (issue.type === "array")
|
|
77
|
-
message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
|
|
78
|
-
else if (issue.type === "string")
|
|
79
|
-
message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
|
|
80
|
-
else if (issue.type === "number")
|
|
81
|
-
message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
|
|
82
|
-
else if (issue.type === "bigint")
|
|
83
|
-
message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
|
|
84
|
-
else if (issue.type === "date")
|
|
85
|
-
message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
|
|
86
|
-
else
|
|
87
|
-
message = "Invalid input";
|
|
88
|
-
break;
|
|
89
|
-
case ZodIssueCode.custom:
|
|
90
|
-
message = `Invalid input`;
|
|
91
|
-
break;
|
|
92
|
-
case ZodIssueCode.invalid_intersection_types:
|
|
93
|
-
message = `Intersection results could not be merged`;
|
|
94
|
-
break;
|
|
95
|
-
case ZodIssueCode.not_multiple_of:
|
|
96
|
-
message = `Number must be a multiple of ${issue.multipleOf}`;
|
|
97
|
-
break;
|
|
98
|
-
case ZodIssueCode.not_finite:
|
|
99
|
-
message = "Number must be finite";
|
|
100
|
-
break;
|
|
101
|
-
default:
|
|
102
|
-
message = _ctx.defaultError;
|
|
103
|
-
util.assertNever(issue);
|
|
104
|
-
}
|
|
105
|
-
return { message };
|
|
106
|
-
};
|
|
107
|
-
export default errorMap;
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The Standard Schema interface.
|
|
3
|
-
*/
|
|
4
|
-
export type StandardSchemaV1<Input = unknown, Output = Input> = {
|
|
5
|
-
/**
|
|
6
|
-
* The Standard Schema properties.
|
|
7
|
-
*/
|
|
8
|
-
readonly "~standard": StandardSchemaV1.Props<Input, Output>;
|
|
9
|
-
};
|
|
10
|
-
export declare namespace StandardSchemaV1 {
|
|
11
|
-
/**
|
|
12
|
-
* The Standard Schema properties interface.
|
|
13
|
-
*/
|
|
14
|
-
export interface Props<Input = unknown, Output = Input> {
|
|
15
|
-
/**
|
|
16
|
-
* The version number of the standard.
|
|
17
|
-
*/
|
|
18
|
-
readonly version: 1;
|
|
19
|
-
/**
|
|
20
|
-
* The vendor name of the schema library.
|
|
21
|
-
*/
|
|
22
|
-
readonly vendor: string;
|
|
23
|
-
/**
|
|
24
|
-
* Validates unknown input values.
|
|
25
|
-
*/
|
|
26
|
-
readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
|
|
27
|
-
/**
|
|
28
|
-
* Inferred types associated with the schema.
|
|
29
|
-
*/
|
|
30
|
-
readonly types?: Types<Input, Output> | undefined;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* The result interface of the validate function.
|
|
34
|
-
*/
|
|
35
|
-
export type Result<Output> = SuccessResult<Output> | FailureResult;
|
|
36
|
-
/**
|
|
37
|
-
* The result interface if validation succeeds.
|
|
38
|
-
*/
|
|
39
|
-
export interface SuccessResult<Output> {
|
|
40
|
-
/**
|
|
41
|
-
* The typed output value.
|
|
42
|
-
*/
|
|
43
|
-
readonly value: Output;
|
|
44
|
-
/**
|
|
45
|
-
* The non-existent issues.
|
|
46
|
-
*/
|
|
47
|
-
readonly issues?: undefined;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* The result interface if validation fails.
|
|
51
|
-
*/
|
|
52
|
-
export interface FailureResult {
|
|
53
|
-
/**
|
|
54
|
-
* The issues of failed validation.
|
|
55
|
-
*/
|
|
56
|
-
readonly issues: ReadonlyArray<Issue>;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* The issue interface of the failure output.
|
|
60
|
-
*/
|
|
61
|
-
export interface Issue {
|
|
62
|
-
/**
|
|
63
|
-
* The error message of the issue.
|
|
64
|
-
*/
|
|
65
|
-
readonly message: string;
|
|
66
|
-
/**
|
|
67
|
-
* The path of the issue, if any.
|
|
68
|
-
*/
|
|
69
|
-
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* The path segment interface of the issue.
|
|
73
|
-
*/
|
|
74
|
-
export interface PathSegment {
|
|
75
|
-
/**
|
|
76
|
-
* The key representing a path segment.
|
|
77
|
-
*/
|
|
78
|
-
readonly key: PropertyKey;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* The Standard Schema types interface.
|
|
82
|
-
*/
|
|
83
|
-
export interface Types<Input = unknown, Output = Input> {
|
|
84
|
-
/**
|
|
85
|
-
* The input type of the schema.
|
|
86
|
-
*/
|
|
87
|
-
readonly input: Input;
|
|
88
|
-
/**
|
|
89
|
-
* The output type of the schema.
|
|
90
|
-
*/
|
|
91
|
-
readonly output: Output;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Infers the input type of a Standard Schema.
|
|
95
|
-
*/
|
|
96
|
-
export type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["input"];
|
|
97
|
-
/**
|
|
98
|
-
* Infers the output type of a Standard Schema.
|
|
99
|
-
*/
|
|
100
|
-
export type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["output"];
|
|
101
|
-
export {};
|
|
102
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export declare class Mocker {
|
|
2
|
-
pick: (...args: any[]) => any;
|
|
3
|
-
get string(): string;
|
|
4
|
-
get number(): number;
|
|
5
|
-
get bigint(): bigint;
|
|
6
|
-
get boolean(): boolean;
|
|
7
|
-
get date(): Date;
|
|
8
|
-
get symbol(): symbol;
|
|
9
|
-
get null(): null;
|
|
10
|
-
get undefined(): undefined;
|
|
11
|
-
get stringOptional(): string | undefined;
|
|
12
|
-
get stringNullable(): string | null;
|
|
13
|
-
get numberOptional(): number | undefined;
|
|
14
|
-
get numberNullable(): number | null;
|
|
15
|
-
get booleanOptional(): boolean | undefined;
|
|
16
|
-
get booleanNullable(): boolean | null;
|
|
17
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
function getRandomInt(max) {
|
|
2
|
-
return Math.floor(Math.random() * Math.floor(max));
|
|
3
|
-
}
|
|
4
|
-
const testSymbol = Symbol("test");
|
|
5
|
-
export class Mocker {
|
|
6
|
-
constructor() {
|
|
7
|
-
this.pick = (...args) => {
|
|
8
|
-
return args[getRandomInt(args.length)];
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
get string() {
|
|
12
|
-
return Math.random().toString(36).substring(7);
|
|
13
|
-
}
|
|
14
|
-
get number() {
|
|
15
|
-
return Math.random() * 100;
|
|
16
|
-
}
|
|
17
|
-
get bigint() {
|
|
18
|
-
return BigInt(Math.floor(Math.random() * 10000));
|
|
19
|
-
}
|
|
20
|
-
get boolean() {
|
|
21
|
-
return Math.random() < 0.5;
|
|
22
|
-
}
|
|
23
|
-
get date() {
|
|
24
|
-
return new Date(Math.floor(Date.now() * Math.random()));
|
|
25
|
-
}
|
|
26
|
-
get symbol() {
|
|
27
|
-
return testSymbol;
|
|
28
|
-
}
|
|
29
|
-
get null() {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
get undefined() {
|
|
33
|
-
return undefined;
|
|
34
|
-
}
|
|
35
|
-
get stringOptional() {
|
|
36
|
-
return this.pick(this.string, this.undefined);
|
|
37
|
-
}
|
|
38
|
-
get stringNullable() {
|
|
39
|
-
return this.pick(this.string, this.null);
|
|
40
|
-
}
|
|
41
|
-
get numberOptional() {
|
|
42
|
-
return this.pick(this.number, this.undefined);
|
|
43
|
-
}
|
|
44
|
-
get numberNullable() {
|
|
45
|
-
return this.pick(this.number, this.null);
|
|
46
|
-
}
|
|
47
|
-
get booleanOptional() {
|
|
48
|
-
return this.pick(this.boolean, this.undefined);
|
|
49
|
-
}
|
|
50
|
-
get booleanNullable() {
|
|
51
|
-
return this.pick(this.boolean, this.null);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import * as z from "zod/v3";
|
|
2
|
-
export declare const filePath: string;
|
|
3
|
-
export declare const Test: z.ZodObject<{
|
|
4
|
-
f1: z.ZodNumber;
|
|
5
|
-
}, "strip", z.ZodTypeAny, {
|
|
6
|
-
f1: number;
|
|
7
|
-
}, {
|
|
8
|
-
f1: number;
|
|
9
|
-
}>;
|
|
10
|
-
export type Test = z.infer<typeof Test>;
|
|
11
|
-
export declare const instanceOfTest: Test;
|
|
12
|
-
export declare const TestMerge: z.ZodObject<{
|
|
13
|
-
f2: z.ZodOptional<z.ZodString>;
|
|
14
|
-
} & {
|
|
15
|
-
f1: z.ZodNumber;
|
|
16
|
-
}, "strip", z.ZodTypeAny, {
|
|
17
|
-
f1: number;
|
|
18
|
-
f2?: string | undefined;
|
|
19
|
-
}, {
|
|
20
|
-
f1: number;
|
|
21
|
-
f2?: string | undefined;
|
|
22
|
-
}>;
|
|
23
|
-
export type TestMerge = z.infer<typeof TestMerge>;
|
|
24
|
-
export declare const instanceOfTestMerge: TestMerge;
|
|
25
|
-
export declare const TestUnion: z.ZodUnion<[z.ZodObject<{
|
|
26
|
-
f2: z.ZodOptional<z.ZodString>;
|
|
27
|
-
}, "strip", z.ZodTypeAny, {
|
|
28
|
-
f2?: string | undefined;
|
|
29
|
-
}, {
|
|
30
|
-
f2?: string | undefined;
|
|
31
|
-
}>, z.ZodObject<{
|
|
32
|
-
f1: z.ZodNumber;
|
|
33
|
-
}, "strip", z.ZodTypeAny, {
|
|
34
|
-
f1: number;
|
|
35
|
-
}, {
|
|
36
|
-
f1: number;
|
|
37
|
-
}>]>;
|
|
38
|
-
export type TestUnion = z.infer<typeof TestUnion>;
|
|
39
|
-
export declare const instanceOfTestUnion: TestUnion;
|
|
40
|
-
export declare const TestPartial: z.ZodObject<{
|
|
41
|
-
f1: z.ZodOptional<z.ZodNumber>;
|
|
42
|
-
}, "strip", z.ZodTypeAny, {
|
|
43
|
-
f1?: number | undefined;
|
|
44
|
-
}, {
|
|
45
|
-
f1?: number | undefined;
|
|
46
|
-
}>;
|
|
47
|
-
export type TestPartial = z.infer<typeof TestPartial>;
|
|
48
|
-
export declare const instanceOfTestPartial: TestPartial;
|
|
49
|
-
export declare const TestPick: z.ZodObject<Pick<{
|
|
50
|
-
f2: z.ZodOptional<z.ZodString>;
|
|
51
|
-
} & {
|
|
52
|
-
f1: z.ZodNumber;
|
|
53
|
-
}, "f1">, "strip", z.ZodTypeAny, {
|
|
54
|
-
f1: number;
|
|
55
|
-
}, {
|
|
56
|
-
f1: number;
|
|
57
|
-
}>;
|
|
58
|
-
export type TestPick = z.infer<typeof TestPick>;
|
|
59
|
-
export declare const instanceOfTestPick: TestPick;
|
|
60
|
-
export declare const TestOmit: z.ZodObject<Omit<{
|
|
61
|
-
f2: z.ZodOptional<z.ZodString>;
|
|
62
|
-
} & {
|
|
63
|
-
f1: z.ZodNumber;
|
|
64
|
-
}, "f2">, "strip", z.ZodTypeAny, {
|
|
65
|
-
f1: number;
|
|
66
|
-
}, {
|
|
67
|
-
f1: number;
|
|
68
|
-
}>;
|
|
69
|
-
export type TestOmit = z.infer<typeof TestOmit>;
|
|
70
|
-
export declare const instanceOfTestOmit: TestOmit;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import * as z from "zod/v3";
|
|
2
|
-
export const filePath = __filename;
|
|
3
|
-
// z.object()
|
|
4
|
-
export const Test = z.object({
|
|
5
|
-
f1: z.number(),
|
|
6
|
-
});
|
|
7
|
-
export const instanceOfTest = {
|
|
8
|
-
f1: 1,
|
|
9
|
-
};
|
|
10
|
-
// z.object().merge()
|
|
11
|
-
export const TestMerge = z
|
|
12
|
-
.object({
|
|
13
|
-
f2: z.string().optional(),
|
|
14
|
-
})
|
|
15
|
-
.merge(Test);
|
|
16
|
-
export const instanceOfTestMerge = {
|
|
17
|
-
f1: 1,
|
|
18
|
-
f2: "string",
|
|
19
|
-
};
|
|
20
|
-
// z.union()
|
|
21
|
-
export const TestUnion = z.union([
|
|
22
|
-
z.object({
|
|
23
|
-
f2: z.string().optional(),
|
|
24
|
-
}),
|
|
25
|
-
Test,
|
|
26
|
-
]);
|
|
27
|
-
export const instanceOfTestUnion = {
|
|
28
|
-
f1: 1,
|
|
29
|
-
f2: "string",
|
|
30
|
-
};
|
|
31
|
-
// z.object().partial()
|
|
32
|
-
export const TestPartial = Test.partial();
|
|
33
|
-
export const instanceOfTestPartial = {
|
|
34
|
-
f1: 1,
|
|
35
|
-
};
|
|
36
|
-
// z.object().pick()
|
|
37
|
-
export const TestPick = TestMerge.pick({ f1: true });
|
|
38
|
-
export const instanceOfTestPick = {
|
|
39
|
-
f1: 1,
|
|
40
|
-
};
|
|
41
|
-
// z.object().omit()
|
|
42
|
-
export const TestOmit = TestMerge.omit({ f2: true });
|
|
43
|
-
export const instanceOfTestOmit = {
|
|
44
|
-
f1: 1,
|
|
45
|
-
};
|