zod 3.25.0-canary.20241210T225910 → 4.0.0-beta.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/dist/commonjs/checks.d.ts +1 -0
- package/dist/commonjs/checks.js +32 -0
- package/dist/commonjs/coerce.d.ts +17 -0
- package/dist/commonjs/coerce.js +57 -0
- package/dist/commonjs/compat.d.ts +47 -0
- package/dist/commonjs/compat.js +73 -0
- package/dist/commonjs/errors.d.ts +23 -0
- package/dist/commonjs/errors.js +57 -0
- package/dist/commonjs/external.d.ts +8 -0
- package/dist/commonjs/external.js +67 -0
- package/dist/commonjs/index.d.ts +4 -0
- package/{lib → dist/commonjs}/index.js +19 -9
- package/dist/commonjs/iso.d.ts +22 -0
- package/dist/commonjs/iso.js +70 -0
- package/dist/commonjs/package.json +3 -0
- package/dist/commonjs/parse.d.ts +17 -0
- package/dist/commonjs/parse.js +44 -0
- package/dist/commonjs/schemas.d.ts +738 -0
- package/dist/commonjs/schemas.js +1171 -0
- package/dist/esm/checks.d.ts +1 -0
- package/dist/esm/checks.js +1 -0
- package/dist/esm/coerce.d.ts +17 -0
- package/dist/esm/coerce.js +17 -0
- package/dist/esm/compat.d.ts +47 -0
- package/dist/esm/compat.js +33 -0
- package/dist/esm/errors.d.ts +23 -0
- package/dist/esm/errors.js +20 -0
- package/dist/esm/external.d.ts +8 -0
- package/dist/esm/external.js +11 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/iso.d.ts +22 -0
- package/dist/esm/iso.js +30 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/parse.d.ts +17 -0
- package/dist/esm/parse.js +8 -0
- package/dist/esm/schemas.d.ts +738 -0
- package/dist/esm/schemas.js +1057 -0
- package/package.json +59 -99
- package/src/checks.ts +30 -0
- package/src/coerce.ts +27 -0
- package/src/compat.ts +74 -0
- package/src/errors.ts +47 -0
- package/src/external.ts +29 -0
- package/src/index.ts +5 -0
- package/src/iso.ts +90 -0
- package/src/parse.ts +32 -0
- package/src/schemas.ts +2324 -0
- package/README.md +0 -3028
- package/index.d.ts +0 -2
- package/lib/ZodError.d.ts +0 -164
- package/lib/ZodError.js +0 -137
- package/lib/__tests__/Mocker.d.ts +0 -17
- package/lib/__tests__/Mocker.js +0 -57
- package/lib/benchmarks/datetime.d.ts +0 -5
- package/lib/benchmarks/datetime.js +0 -54
- package/lib/benchmarks/discriminatedUnion.d.ts +0 -5
- package/lib/benchmarks/discriminatedUnion.js +0 -79
- package/lib/benchmarks/index.d.ts +0 -1
- package/lib/benchmarks/index.js +0 -59
- package/lib/benchmarks/ipv4.d.ts +0 -5
- package/lib/benchmarks/ipv4.js +0 -54
- package/lib/benchmarks/object.d.ts +0 -5
- package/lib/benchmarks/object.js +0 -70
- package/lib/benchmarks/primitives.d.ts +0 -5
- package/lib/benchmarks/primitives.js +0 -170
- package/lib/benchmarks/realworld.d.ts +0 -5
- package/lib/benchmarks/realworld.js +0 -56
- package/lib/benchmarks/string.d.ts +0 -5
- package/lib/benchmarks/string.js +0 -55
- package/lib/benchmarks/union.d.ts +0 -5
- package/lib/benchmarks/union.js +0 -79
- package/lib/errors.d.ts +0 -5
- package/lib/errors.js +0 -17
- package/lib/external.d.ts +0 -6
- package/lib/external.js +0 -22
- package/lib/helpers/enumUtil.d.ts +0 -8
- package/lib/helpers/enumUtil.js +0 -2
- package/lib/helpers/errorUtil.d.ts +0 -9
- package/lib/helpers/errorUtil.js +0 -8
- package/lib/helpers/parseUtil.d.ts +0 -78
- package/lib/helpers/parseUtil.js +0 -125
- package/lib/helpers/partialUtil.d.ts +0 -8
- package/lib/helpers/partialUtil.js +0 -2
- package/lib/helpers/typeAliases.d.ts +0 -2
- package/lib/helpers/typeAliases.js +0 -2
- package/lib/helpers/util.d.ts +0 -82
- package/lib/helpers/util.js +0 -142
- package/lib/index.d.ts +0 -4
- package/lib/index.mjs +0 -4382
- package/lib/index.umd.js +0 -4497
- package/lib/locales/en.d.ts +0 -3
- package/lib/locales/en.js +0 -129
- package/lib/standard-schema.d.ts +0 -102
- package/lib/standard-schema.js +0 -2
- package/lib/types.d.ts +0 -1062
- package/lib/types.js +0 -3823
package/package.json
CHANGED
|
@@ -1,68 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zod",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"type": "git",
|
|
7
|
-
"url": "git+https://github.com/colinhacks/zod.git"
|
|
8
|
-
},
|
|
9
|
-
"main": "./lib/index.js",
|
|
10
|
-
"module": "./lib/index.mjs",
|
|
11
|
-
"devDependencies": {
|
|
12
|
-
"@babel/core": "^7.22.5",
|
|
13
|
-
"@babel/preset-env": "^7.22.5",
|
|
14
|
-
"@babel/preset-typescript": "^7.22.5",
|
|
15
|
-
"@jest/globals": "^29.4.3",
|
|
16
|
-
"@rollup/plugin-typescript": "^8.2.0",
|
|
17
|
-
"@standard-schema/spec": "^1.0.0-beta.4",
|
|
18
|
-
"@swc/core": "^1.3.66",
|
|
19
|
-
"@swc/jest": "^0.2.26",
|
|
20
|
-
"@types/benchmark": "^2.1.0",
|
|
21
|
-
"@types/jest": "^29.2.2",
|
|
22
|
-
"@types/node": "14",
|
|
23
|
-
"@typescript-eslint/eslint-plugin": "^5.15.0",
|
|
24
|
-
"@typescript-eslint/parser": "^5.15.0",
|
|
25
|
-
"babel-jest": "^29.5.0",
|
|
26
|
-
"benchmark": "^2.1.4",
|
|
27
|
-
"dependency-cruiser": "^9.19.0",
|
|
28
|
-
"eslint": "^8.11.0",
|
|
29
|
-
"eslint-config-prettier": "^8.5.0",
|
|
30
|
-
"eslint-plugin-ban": "^1.6.0",
|
|
31
|
-
"eslint-plugin-import": "^2.25.4",
|
|
32
|
-
"eslint-plugin-simple-import-sort": "^7.0.0",
|
|
33
|
-
"eslint-plugin-unused-imports": "^2.0.0",
|
|
34
|
-
"husky": "^7.0.4",
|
|
35
|
-
"jest": "^29.3.1",
|
|
36
|
-
"lint-staged": "^12.3.7",
|
|
37
|
-
"netlify-cli": "^17.26.2",
|
|
38
|
-
"nodemon": "^2.0.15",
|
|
39
|
-
"prettier": "^2.6.0",
|
|
40
|
-
"pretty-quick": "^3.1.3",
|
|
41
|
-
"rollup": "^2.70.1",
|
|
42
|
-
"ts-jest": "^29.1.0",
|
|
43
|
-
"ts-morph": "^14.0.0",
|
|
44
|
-
"ts-node": "^10.9.1",
|
|
45
|
-
"tslib": "^2.3.1",
|
|
46
|
-
"tsx": "^3.8.0",
|
|
47
|
-
"typescript": "^5.0.0",
|
|
48
|
-
"vitest": "^0.32.2"
|
|
49
|
-
},
|
|
50
|
-
"exports": {
|
|
51
|
-
".": {
|
|
52
|
-
"types": "./index.d.ts",
|
|
53
|
-
"require": "./lib/index.js",
|
|
54
|
-
"import": "./lib/index.mjs"
|
|
55
|
-
},
|
|
56
|
-
"./package.json": "./package.json",
|
|
57
|
-
"./locales/*": "./lib/locales/*"
|
|
58
|
-
},
|
|
59
|
-
"bugs": {
|
|
60
|
-
"url": "https://github.com/colinhacks/zod/issues"
|
|
61
|
-
},
|
|
3
|
+
"version": "4.0.0-beta.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"author": "Colin McDonnell <zod@colinhacks.com>",
|
|
62
6
|
"description": "TypeScript-first schema declaration and validation library with static type inference",
|
|
63
7
|
"files": [
|
|
64
|
-
"
|
|
65
|
-
"
|
|
8
|
+
"src",
|
|
9
|
+
"dist"
|
|
66
10
|
],
|
|
67
11
|
"funding": "https://github.com/sponsors/colinhacks",
|
|
68
12
|
"homepage": "https://zod.dev",
|
|
@@ -74,49 +18,65 @@
|
|
|
74
18
|
"inference"
|
|
75
19
|
],
|
|
76
20
|
"license": "MIT",
|
|
77
|
-
"
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
"
|
|
83
|
-
|
|
21
|
+
"sideEffects": false,
|
|
22
|
+
"main": "./dist/commonjs/index.js",
|
|
23
|
+
"module": "./dist/esm/index.js",
|
|
24
|
+
"types": "./dist/commonjs/index.d.ts",
|
|
25
|
+
"exports": {
|
|
26
|
+
"./package.json": "./package.json",
|
|
27
|
+
".": {
|
|
28
|
+
"import": {
|
|
29
|
+
"@zod/source": "./src/index.ts",
|
|
30
|
+
"types": "./dist/esm/index.d.ts",
|
|
31
|
+
"default": "./dist/esm/index.js"
|
|
32
|
+
},
|
|
33
|
+
"require": {
|
|
34
|
+
"types": "./dist/commonjs/index.d.ts",
|
|
35
|
+
"default": "./dist/commonjs/index.js"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"./locales/*": {
|
|
39
|
+
"import": {
|
|
40
|
+
"@zod/source": "./src/locales/*",
|
|
41
|
+
"types": "./dist/esm/locales/*",
|
|
42
|
+
"default": "./dist/esm/locales/*"
|
|
43
|
+
},
|
|
44
|
+
"require": {
|
|
45
|
+
"types": "./dist/commonjs/locales/*",
|
|
46
|
+
"default": "./dist/commonjs/locales/*"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"tshy": {
|
|
51
|
+
"exports": {
|
|
52
|
+
"./package.json": "./package.json",
|
|
53
|
+
".": "./src/index.ts",
|
|
54
|
+
"./locales/*": "./src/locales/*"
|
|
55
|
+
},
|
|
56
|
+
"sourceDialects": [
|
|
57
|
+
"@zod/source"
|
|
84
58
|
]
|
|
85
59
|
},
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
"
|
|
92
|
-
"fix": "yarn lint:fix && yarn prettier:fix",
|
|
93
|
-
"clean": "rm -rf lib/* deno/lib/*",
|
|
94
|
-
"build": "yarn run clean && npm run build:cjs && npm run build:esm && npm run build:deno",
|
|
95
|
-
"build:deno": "node ./deno-build.mjs && cp ./README.md ./deno/lib",
|
|
96
|
-
"build:esm": "rollup --config ./configs/rollup.config.js",
|
|
97
|
-
"build:cjs": "tsc -p ./configs/tsconfig.cjs.json",
|
|
98
|
-
"build:types": "tsc -p ./configs/tsconfig.types.json",
|
|
99
|
-
"build:test": "tsc -p ./configs/tsconfig.test.json",
|
|
100
|
-
"test:watch": "yarn test:ts-jest --watch",
|
|
101
|
-
"test": "yarn test:ts-jest",
|
|
102
|
-
"test:babel": "jest --coverage --config ./configs/babel-jest.config.json",
|
|
103
|
-
"test:bun": "bun test src/",
|
|
104
|
-
"test:vitest": "npx vitest --config ./configs/vitest.config.ts",
|
|
105
|
-
"test:ts-jest": "npx jest --config ./configs/ts-jest.config.json",
|
|
106
|
-
"test:swc": "npx jest --config ./configs/swc-jest.config.json",
|
|
107
|
-
"test:deno": "cd deno && deno test",
|
|
108
|
-
"prepublishOnly": "npm run test && npm run build && npm run build:deno",
|
|
109
|
-
"play": "nodemon -e ts -w . -x tsx playground.ts",
|
|
110
|
-
"depcruise": "depcruise -c .dependency-cruiser.js src",
|
|
111
|
-
"benchmark": "tsx src/benchmarks/index.ts",
|
|
112
|
-
"prepare": "husky install",
|
|
113
|
-
"docs": "netlify dev"
|
|
60
|
+
"repository": {
|
|
61
|
+
"type": "git",
|
|
62
|
+
"url": "git+https://github.com/colinhacks/zod.git"
|
|
63
|
+
},
|
|
64
|
+
"bugs": {
|
|
65
|
+
"url": "https://github.com/colinhacks/zod/issues"
|
|
114
66
|
},
|
|
115
|
-
"sideEffects": false,
|
|
116
67
|
"support": {
|
|
117
68
|
"backing": {
|
|
118
69
|
"npm-funding": true
|
|
119
70
|
}
|
|
120
71
|
},
|
|
121
|
-
"
|
|
122
|
-
|
|
72
|
+
"dependencies": {
|
|
73
|
+
"@zod/core": "0.1.0"
|
|
74
|
+
},
|
|
75
|
+
"scripts": {
|
|
76
|
+
"clean": "rm -rf dist",
|
|
77
|
+
"build": "tshy",
|
|
78
|
+
"postbuild": "pnpm biome check --write .",
|
|
79
|
+
"test:watch": "pnpm vitest",
|
|
80
|
+
"test": "pnpm vitest run"
|
|
81
|
+
}
|
|
82
|
+
}
|
package/src/checks.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export {
|
|
2
|
+
_lt as lt,
|
|
3
|
+
_lte as lte,
|
|
4
|
+
_gt as gt,
|
|
5
|
+
_gte as gte,
|
|
6
|
+
_positive as positive,
|
|
7
|
+
_negative as negative,
|
|
8
|
+
_nonpositive as nonpositive,
|
|
9
|
+
_nonnegative as nonnegative,
|
|
10
|
+
_multipleOf as multipleOf,
|
|
11
|
+
_maxSize as maxSize,
|
|
12
|
+
_minSize as minSize,
|
|
13
|
+
_size as size,
|
|
14
|
+
_maxLength as maxLength,
|
|
15
|
+
_minLength as minLength,
|
|
16
|
+
_length as length,
|
|
17
|
+
_regex as regex,
|
|
18
|
+
_lowercase as lowercase,
|
|
19
|
+
_uppercase as uppercase,
|
|
20
|
+
_includes as includes,
|
|
21
|
+
_startsWith as startsWith,
|
|
22
|
+
_endsWith as endsWith,
|
|
23
|
+
_property as property,
|
|
24
|
+
_mime as mime,
|
|
25
|
+
_overwrite as overwrite,
|
|
26
|
+
_normalize as normalize,
|
|
27
|
+
_trim as trim,
|
|
28
|
+
_toLowerCase as toLowerCase,
|
|
29
|
+
_toUpperCase as toUpperCase,
|
|
30
|
+
} from "@zod/core";
|
package/src/coerce.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as core from "@zod/core";
|
|
2
|
+
import * as schemas from "./schemas.js";
|
|
3
|
+
|
|
4
|
+
export interface ZodCoercedString extends schemas._ZodString<unknown> {}
|
|
5
|
+
export function string(params?: string | core.$ZodStringParams): ZodCoercedString {
|
|
6
|
+
return core._coercedString(schemas.ZodString, params);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface ZodCoercedNumber extends schemas._ZodNumber<unknown> {}
|
|
10
|
+
export function number(params?: string | core.$ZodNumberParams): ZodCoercedNumber {
|
|
11
|
+
return core._coercedNumber(schemas.ZodNumber, params);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface ZodCoercedBoolean extends schemas._ZodBoolean<unknown> {}
|
|
15
|
+
export function boolean(params?: string | core.$ZodBooleanParams): ZodCoercedBoolean {
|
|
16
|
+
return core._coercedBoolean(schemas.ZodBoolean, params);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface ZodCoercedBigInt extends schemas._ZodBigInt<unknown> {}
|
|
20
|
+
export function bigint(params?: string | core.$ZodBigIntParams): ZodCoercedBigInt {
|
|
21
|
+
return core._coercedBigint(schemas.ZodBigInt, params);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface ZodCoercedDate extends schemas._ZodDate<unknown> {}
|
|
25
|
+
export function date(params?: string | core.$ZodDateParams): ZodCoercedDate {
|
|
26
|
+
return core._coercedDate(schemas.ZodDate, params);
|
|
27
|
+
}
|
package/src/compat.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// Zod 3 compat layer
|
|
2
|
+
|
|
3
|
+
import * as core from "@zod/core";
|
|
4
|
+
import type { ZodType } from "./schemas.js";
|
|
5
|
+
|
|
6
|
+
export type {
|
|
7
|
+
/** @deprecated Use `z.output<T>` instead. */
|
|
8
|
+
output as TypeOf,
|
|
9
|
+
/** @deprecated Use `z.output<T>` instead. */
|
|
10
|
+
output as Infer,
|
|
11
|
+
/** @deprecated Use `z.core.$$ZodFirstPartyTypes` instead */
|
|
12
|
+
$ZodTypes as ZodFirstPartySchemaTypes,
|
|
13
|
+
} from "@zod/core";
|
|
14
|
+
|
|
15
|
+
/** @deprecated Use the raw string literal codes instead, e.g. "invalid_type". */
|
|
16
|
+
export const ZodIssueCode = {
|
|
17
|
+
invalid_type: "invalid_type",
|
|
18
|
+
too_big: "too_big",
|
|
19
|
+
too_small: "too_small",
|
|
20
|
+
invalid_format: "invalid_format",
|
|
21
|
+
not_multiple_of: "not_multiple_of",
|
|
22
|
+
unrecognized_keys: "unrecognized_keys",
|
|
23
|
+
invalid_union: "invalid_union",
|
|
24
|
+
invalid_key: "invalid_key",
|
|
25
|
+
invalid_element: "invalid_element",
|
|
26
|
+
invalid_value: "invalid_value",
|
|
27
|
+
custom: "custom",
|
|
28
|
+
} as const;
|
|
29
|
+
|
|
30
|
+
/** @deprecated Not necessary in Zod 4. */
|
|
31
|
+
type INVALID = { status: "aborted" };
|
|
32
|
+
/** @deprecated Not necessary in Zod 4. */
|
|
33
|
+
const INVALID: INVALID = Object.freeze({
|
|
34
|
+
status: "aborted",
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
/** A special constant with type `never` */
|
|
38
|
+
export const NEVER = INVALID as never;
|
|
39
|
+
|
|
40
|
+
/** @deprecated Use `z.$ZodFlattenedError` */
|
|
41
|
+
export type inferFlattenedErrors<T extends core.$ZodType, U = string> = core.$ZodFlattenedError<core.output<T>, U>;
|
|
42
|
+
|
|
43
|
+
/** @deprecated Use `z.$ZodFormattedError` */
|
|
44
|
+
export type inferFormattedError<T extends core.$ZodType<any, any>, U = string> = core.$ZodFormattedError<
|
|
45
|
+
core.output<T>,
|
|
46
|
+
U
|
|
47
|
+
>;
|
|
48
|
+
|
|
49
|
+
/** Use `z.$brand` instead */
|
|
50
|
+
export type BRAND<T extends string | number | symbol = string | number | symbol> = {
|
|
51
|
+
[core.$brand]: { [k in T]: true };
|
|
52
|
+
};
|
|
53
|
+
export { $brand, config } from "@zod/core";
|
|
54
|
+
|
|
55
|
+
/** @deprecated Use `z.config(params)` instead. */
|
|
56
|
+
export function setErrorMap(map: core.$ZodErrorMap): void {
|
|
57
|
+
core.config({
|
|
58
|
+
customError: map,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** @deprecated Use `z.config()` instead. */
|
|
63
|
+
export function getErrorMap(): core.$ZodErrorMap<core.$ZodIssue> | undefined {
|
|
64
|
+
return core.config().customError;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export type {
|
|
68
|
+
/** @deprecated Use z.ZodType (without generics) instead. */
|
|
69
|
+
ZodType as ZodTypeAny,
|
|
70
|
+
/** @deprecated Use `z.ZodType` */
|
|
71
|
+
ZodType as ZodSchema,
|
|
72
|
+
/** @deprecated Use `z.ZodType` */
|
|
73
|
+
ZodType as Schema,
|
|
74
|
+
};
|
package/src/errors.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import * as core from "@zod/core";
|
|
2
|
+
import type { AnyFunc } from "@zod/core/util";
|
|
3
|
+
|
|
4
|
+
/** @deprecated Use `z.core.$ZodIssue` from `@zod/core` instead, especially if you are building a library on top of Zod. */
|
|
5
|
+
export type ZodIssue = core.$ZodIssue;
|
|
6
|
+
|
|
7
|
+
export class ZodError<T = unknown> extends core.$ZodError<T> {
|
|
8
|
+
/** @deprecated Use the `z.formatError(err)` function instead. */
|
|
9
|
+
format(): core.$ZodFormattedError<T>;
|
|
10
|
+
format<U>(mapper: (issue: core.$ZodIssue) => U): core.$ZodFormattedError<T, U>;
|
|
11
|
+
format(mapper?: AnyFunc): any {
|
|
12
|
+
return core.formatError(this, mapper);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** @deprecated Use the `z.flattenError(err)` function instead. */
|
|
16
|
+
flatten(): core.$ZodFlattenedError<T>;
|
|
17
|
+
flatten<U>(mapper: (issue: core.$ZodIssue) => U): core.$ZodFlattenedError<T, U>;
|
|
18
|
+
flatten(mapper?: AnyFunc): core.$ZodFlattenedError<T> {
|
|
19
|
+
return core.flattenError(this, mapper);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
addIssue(issue: core.$ZodIssue): void {
|
|
23
|
+
this.issues.push(issue);
|
|
24
|
+
}
|
|
25
|
+
addIssues(issues: core.$ZodIssue[]): void {
|
|
26
|
+
this.issues.push(...issues);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
get isEmpty(): boolean {
|
|
30
|
+
return this.issues.length === 0;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type {
|
|
35
|
+
/** @deprecated Use `z.core.$ZodFlattenedError` instead. */
|
|
36
|
+
$ZodFlattenedError as ZodFlattenedError,
|
|
37
|
+
/** @deprecated Use `z.core.$ZodFormattedError` instead. */
|
|
38
|
+
$ZodFormattedError as ZodFormattedError,
|
|
39
|
+
/** @deprecated Use `z.core.$ZodErrorMap` instead. */
|
|
40
|
+
$ZodErrorMap as ZodErrorMap,
|
|
41
|
+
} from "@zod/core";
|
|
42
|
+
|
|
43
|
+
/** @deprecated Use `z.core.$ZodRawIssue` instead. */
|
|
44
|
+
export type IssueData = core.$ZodRawIssue;
|
|
45
|
+
|
|
46
|
+
// /** @deprecated Use `z.core.$ZodErrorMapCtx` instead. */
|
|
47
|
+
// export type ErrorMapCtx = core.$ZodErrorMapCtx;
|
package/src/external.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export * as core from "@zod/core";
|
|
2
|
+
export * from "./schemas.js";
|
|
3
|
+
export * from "./checks.js";
|
|
4
|
+
export * from "./errors.js";
|
|
5
|
+
export * from "./parse.js";
|
|
6
|
+
export * from "./compat.js";
|
|
7
|
+
|
|
8
|
+
// zod-specified
|
|
9
|
+
import { config } from "@zod/core";
|
|
10
|
+
import en from "@zod/core/locales/en.js";
|
|
11
|
+
config(en());
|
|
12
|
+
|
|
13
|
+
export type { infer, output, input } from "@zod/core";
|
|
14
|
+
export {
|
|
15
|
+
globalRegistry,
|
|
16
|
+
registry,
|
|
17
|
+
config,
|
|
18
|
+
$output,
|
|
19
|
+
$input,
|
|
20
|
+
$brand,
|
|
21
|
+
function,
|
|
22
|
+
clone,
|
|
23
|
+
regexes,
|
|
24
|
+
flattenError,
|
|
25
|
+
formatError,
|
|
26
|
+
treeifyError,
|
|
27
|
+
prettifyError,
|
|
28
|
+
toJSONSchema,
|
|
29
|
+
} from "@zod/core";
|
package/src/index.ts
ADDED
package/src/iso.ts
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import * as core from "@zod/core";
|
|
2
|
+
import * as schemas from "./schemas.js";
|
|
3
|
+
|
|
4
|
+
//////////////////////////////////////////////
|
|
5
|
+
//////////////////////////////////////////////
|
|
6
|
+
////////// //////////
|
|
7
|
+
////////// ZodISODateTime //////////
|
|
8
|
+
////////// //////////
|
|
9
|
+
//////////////////////////////////////////////
|
|
10
|
+
//////////////////////////////////////////////
|
|
11
|
+
|
|
12
|
+
export interface ZodISODateTime extends schemas.ZodStringFormat {
|
|
13
|
+
_zod: core.$ZodISODateTimeInternals;
|
|
14
|
+
}
|
|
15
|
+
export const ZodISODateTime: core.$constructor<ZodISODateTime> = /*@__PURE__*/ core.$constructor(
|
|
16
|
+
"ZodISODateTime",
|
|
17
|
+
(inst, def) => {
|
|
18
|
+
core.$ZodISODateTime.init(inst, def);
|
|
19
|
+
schemas.ZodStringFormat.init(inst, def);
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
export function datetime(params?: string | core.$ZodISODateTimeParams): ZodISODateTime {
|
|
24
|
+
return core._isoDateTime(ZodISODateTime, params);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//////////////////////////////////////////
|
|
28
|
+
//////////////////////////////////////////
|
|
29
|
+
////////// //////////
|
|
30
|
+
////////// ZodISODate //////////
|
|
31
|
+
////////// //////////
|
|
32
|
+
//////////////////////////////////////////
|
|
33
|
+
//////////////////////////////////////////
|
|
34
|
+
|
|
35
|
+
export interface ZodISODate extends schemas.ZodStringFormat {
|
|
36
|
+
_zod: core.$ZodISODateInternals;
|
|
37
|
+
}
|
|
38
|
+
export const ZodISODate: core.$constructor<ZodISODate> = /*@__PURE__*/ core.$constructor("ZodISODate", (inst, def) => {
|
|
39
|
+
core.$ZodISODate.init(inst, def);
|
|
40
|
+
schemas.ZodStringFormat.init(inst, def);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
export function date(params?: string | core.$ZodISODateParams): ZodISODate {
|
|
44
|
+
return core._isoDate(ZodISODate, params);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// ZodISOTime
|
|
48
|
+
|
|
49
|
+
//////////////////////////////////////////
|
|
50
|
+
//////////////////////////////////////////
|
|
51
|
+
////////// //////////
|
|
52
|
+
////////// ZodISOTime //////////
|
|
53
|
+
////////// //////////
|
|
54
|
+
//////////////////////////////////////////
|
|
55
|
+
//////////////////////////////////////////
|
|
56
|
+
|
|
57
|
+
export interface ZodISOTime extends schemas.ZodStringFormat {
|
|
58
|
+
_zod: core.$ZodISOTimeInternals;
|
|
59
|
+
}
|
|
60
|
+
export const ZodISOTime: core.$constructor<ZodISOTime> = /*@__PURE__*/ core.$constructor("ZodISOTime", (inst, def) => {
|
|
61
|
+
core.$ZodISOTime.init(inst, def);
|
|
62
|
+
schemas.ZodStringFormat.init(inst, def);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
export function time(params?: string | core.$ZodISOTimeParams): ZodISOTime {
|
|
66
|
+
return core._isoTime(ZodISOTime, params);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
//////////////////////////////////////////////
|
|
70
|
+
//////////////////////////////////////////////
|
|
71
|
+
////////// //////////
|
|
72
|
+
////////// ZodISODuration //////////
|
|
73
|
+
////////// //////////
|
|
74
|
+
//////////////////////////////////////////////
|
|
75
|
+
//////////////////////////////////////////////
|
|
76
|
+
|
|
77
|
+
export interface ZodISODuration extends schemas.ZodStringFormat {
|
|
78
|
+
_zod: core.$ZodISODurationInternals;
|
|
79
|
+
}
|
|
80
|
+
export const ZodISODuration: core.$constructor<ZodISODuration> = /*@__PURE__*/ core.$constructor(
|
|
81
|
+
"ZodISODuration",
|
|
82
|
+
(inst, def) => {
|
|
83
|
+
core.$ZodISODuration.init(inst, def);
|
|
84
|
+
schemas.ZodStringFormat.init(inst, def);
|
|
85
|
+
}
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
export function duration(params?: string | core.$ZodISODurationParams): ZodISODuration {
|
|
89
|
+
return core._isoDuration(ZodISODuration, params);
|
|
90
|
+
}
|
package/src/parse.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as core from "@zod/core";
|
|
2
|
+
import { ZodError } from "./errors.js";
|
|
3
|
+
|
|
4
|
+
export type ZodSafeParseResult<T> = ZodSafeParseSuccess<T> | ZodSafeParseError<T>;
|
|
5
|
+
export type ZodSafeParseSuccess<T> = { success: true; data: T; error?: never };
|
|
6
|
+
export type ZodSafeParseError<T> = { success: false; data?: never; error: ZodError<T> };
|
|
7
|
+
|
|
8
|
+
export const parse: <T extends core.$ZodType>(
|
|
9
|
+
schema: T,
|
|
10
|
+
value: unknown,
|
|
11
|
+
_ctx?: core.ParseContext<core.$ZodIssue>
|
|
12
|
+
) => core.output<T> = /* @__PURE__ */ core._parse.bind({ Error: ZodError }) as any;
|
|
13
|
+
|
|
14
|
+
export const safeParse: <T extends core.$ZodType>(
|
|
15
|
+
schema: T,
|
|
16
|
+
value: unknown,
|
|
17
|
+
_ctx?: core.ParseContext<core.$ZodIssue>
|
|
18
|
+
) => ZodSafeParseResult<core.output<T>> = /* @__PURE__ */ core._safeParse.bind({ Error: ZodError }) as any;
|
|
19
|
+
|
|
20
|
+
export const parseAsync: <T extends core.$ZodType>(
|
|
21
|
+
schema: T,
|
|
22
|
+
value: unknown,
|
|
23
|
+
_ctx?: core.ParseContext<core.$ZodIssue>
|
|
24
|
+
) => Promise<core.output<T>> = /* @__PURE__ */ core._parseAsync.bind({ Error: ZodError }) as any;
|
|
25
|
+
|
|
26
|
+
export const safeParseAsync: <T extends core.$ZodType>(
|
|
27
|
+
schema: T,
|
|
28
|
+
value: unknown,
|
|
29
|
+
_ctx?: core.ParseContext<core.$ZodIssue>
|
|
30
|
+
) => Promise<ZodSafeParseResult<core.output<T>>> = /* @__PURE__ */ core._safeParseAsync.bind({
|
|
31
|
+
Error: ZodError,
|
|
32
|
+
}) as any;
|