zod 4.0.0-beta.1 → 4.0.0-beta.20250409T222615

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.
Files changed (102) hide show
  1. package/LICENSE +1 -1
  2. package/dist/commonjs/checks.d.ts +1 -0
  3. package/dist/commonjs/checks.js +32 -0
  4. package/dist/commonjs/coerce.d.ts +17 -0
  5. package/dist/commonjs/coerce.js +57 -0
  6. package/dist/commonjs/compat.d.ts +47 -0
  7. package/dist/commonjs/compat.js +73 -0
  8. package/dist/commonjs/errors.d.ts +28 -0
  9. package/dist/commonjs/errors.js +60 -0
  10. package/dist/commonjs/external.d.ts +8 -0
  11. package/dist/commonjs/external.js +67 -0
  12. package/dist/commonjs/index.d.ts +4 -0
  13. package/dist/commonjs/index.js +43 -0
  14. package/dist/commonjs/iso.d.ts +22 -0
  15. package/dist/commonjs/iso.js +70 -0
  16. package/dist/commonjs/package.json +3 -0
  17. package/dist/commonjs/parse.d.ts +17 -0
  18. package/dist/commonjs/parse.js +44 -0
  19. package/dist/commonjs/schemas.d.ts +738 -0
  20. package/dist/commonjs/schemas.js +1171 -0
  21. package/dist/esm/checks.d.ts +1 -0
  22. package/dist/esm/checks.js +1 -0
  23. package/dist/esm/coerce.d.ts +17 -0
  24. package/dist/esm/coerce.js +17 -0
  25. package/dist/esm/compat.d.ts +47 -0
  26. package/dist/esm/compat.js +33 -0
  27. package/dist/esm/errors.d.ts +28 -0
  28. package/dist/esm/errors.js +23 -0
  29. package/dist/esm/external.d.ts +8 -0
  30. package/dist/esm/external.js +14 -0
  31. package/dist/esm/index.d.ts +4 -0
  32. package/dist/esm/index.js +4 -0
  33. package/dist/esm/iso.d.ts +22 -0
  34. package/dist/esm/iso.js +30 -0
  35. package/dist/esm/package.json +3 -0
  36. package/dist/esm/parse.d.ts +17 -0
  37. package/dist/esm/parse.js +8 -0
  38. package/dist/esm/schemas.d.ts +738 -0
  39. package/dist/esm/schemas.js +1057 -0
  40. package/package.json +66 -82
  41. package/src/checks.ts +30 -0
  42. package/src/coerce.ts +27 -0
  43. package/src/compat.ts +74 -0
  44. package/src/errors.ts +52 -0
  45. package/src/external.ts +29 -0
  46. package/src/index.ts +5 -0
  47. package/src/iso.ts +90 -0
  48. package/src/parse.ts +32 -0
  49. package/src/schemas.ts +2324 -0
  50. package/CHANGELOG.md +0 -160
  51. package/README.md +0 -1730
  52. package/lib/.DS_Store +0 -0
  53. package/lib/PseudoPromise.d.ts +0 -7
  54. package/lib/PseudoPromise.d.ts.map +0 -1
  55. package/lib/PseudoPromise.js +0 -17
  56. package/lib/PseudoPromise.js.map +0 -1
  57. package/lib/ZodError.d.ts +0 -137
  58. package/lib/ZodError.d.ts.map +0 -1
  59. package/lib/ZodError.js +0 -301
  60. package/lib/ZodError.js.map +0 -1
  61. package/lib/benchmarks/index.d.ts +0 -2
  62. package/lib/benchmarks/index.d.ts.map +0 -1
  63. package/lib/benchmarks/index.js +0 -54
  64. package/lib/benchmarks/index.js.map +0 -1
  65. package/lib/benchmarks/object.d.ts +0 -6
  66. package/lib/benchmarks/object.d.ts.map +0 -1
  67. package/lib/benchmarks/object.js +0 -71
  68. package/lib/benchmarks/object.js.map +0 -1
  69. package/lib/benchmarks/string.d.ts +0 -6
  70. package/lib/benchmarks/string.d.ts.map +0 -1
  71. package/lib/benchmarks/string.js +0 -45
  72. package/lib/benchmarks/string.js.map +0 -1
  73. package/lib/external.d.ts +0 -4
  74. package/lib/external.d.ts.map +0 -1
  75. package/lib/external.js +0 -16
  76. package/lib/external.js.map +0 -1
  77. package/lib/helpers/errorUtil.d.ts +0 -10
  78. package/lib/helpers/errorUtil.d.ts.map +0 -1
  79. package/lib/helpers/errorUtil.js +0 -13
  80. package/lib/helpers/errorUtil.js.map +0 -1
  81. package/lib/helpers/parseUtil.d.ts +0 -74
  82. package/lib/helpers/parseUtil.d.ts.map +0 -1
  83. package/lib/helpers/parseUtil.js +0 -179
  84. package/lib/helpers/parseUtil.js.map +0 -1
  85. package/lib/helpers/partialUtil.d.ts +0 -18
  86. package/lib/helpers/partialUtil.d.ts.map +0 -1
  87. package/lib/helpers/partialUtil.js +0 -3
  88. package/lib/helpers/partialUtil.js.map +0 -1
  89. package/lib/helpers/util.d.ts +0 -18
  90. package/lib/helpers/util.d.ts.map +0 -1
  91. package/lib/helpers/util.js +0 -87
  92. package/lib/helpers/util.js.map +0 -1
  93. package/lib/index.d.ts +0 -4
  94. package/lib/index.d.ts.map +0 -1
  95. package/lib/index.js +0 -29
  96. package/lib/index.js.map +0 -1
  97. package/lib/index.mjs +0 -2808
  98. package/lib/index.mjs.map +0 -1
  99. package/lib/types.d.ts +0 -541
  100. package/lib/types.d.ts.map +0 -1
  101. package/lib/types.js +0 -2282
  102. package/lib/types.js.map +0 -1
package/package.json CHANGED
@@ -1,34 +1,15 @@
1
1
  {
2
2
  "name": "zod",
3
- "version": "4.0.0-beta.1",
3
+ "version": "4.0.0-beta.20250409T222615",
4
+ "type": "module",
5
+ "author": "Colin McDonnell <zod@colinhacks.com>",
4
6
  "description": "TypeScript-first schema declaration and validation library with static type inference",
5
- "main": "./lib/index.js",
6
- "types": "./lib/index.d.ts",
7
- "module": "./lib/index.mjs",
8
- "exports": {
9
- "require": "./lib/index.js",
10
- "import": "./lib/index.mjs"
11
- },
12
7
  "files": [
13
- "/lib"
8
+ "src",
9
+ "dist"
14
10
  ],
15
- "repository": {
16
- "type": "git",
17
- "url": "https://github.com/colinhacks/zod"
18
- },
19
- "author": "Colin McDonnell <colin@colinhacks.com>",
20
- "license": "MIT",
21
- "sideEffects": false,
22
- "bugs": {
23
- "url": "https://github.com/colinhacks/zod/issues"
24
- },
25
- "homepage": "https://github.com/colinhacks/zod",
26
11
  "funding": "https://github.com/sponsors/colinhacks",
27
- "support": {
28
- "backing": {
29
- "npm-funding": true
30
- }
31
- },
12
+ "homepage": "https://zod.dev",
32
13
  "keywords": [
33
14
  "typescript",
34
15
  "schema",
@@ -36,65 +17,68 @@
36
17
  "type",
37
18
  "inference"
38
19
  ],
39
- "scripts": {
40
- "check:format": "prettier --check \"src/**/*.ts\" \"deno/lib/**/*.ts\"",
41
- "fix:format": "prettier --write \"src/**/*.ts\" \"deno/lib/**/*.ts\"",
42
- "check:lint": "eslint --ext .ts ./src",
43
- "fix:lint": "eslint --fix --ext .ts ./src",
44
- "check": "yarn check:lint && yarn check:format",
45
- "fix": "yarn fix:lint && yarn fix:format",
46
- "clean": "rm -rf lib/* deno/lib/*",
47
- "build": "yarn run clean && npm run build:cjs && npm run build:esm && npm run build:deno",
48
- "build:deno": "node ./deno/build.mjs",
49
- "build:esm": "rollup --config rollup.config.js",
50
- "build:cjs": "tsc --p tsconfig.cjs.json",
51
- "build:types": "tsc --p tsconfig.types.json",
52
- "rollup": "rollup --config rollup.config.js",
53
- "test": "node --trace-warnings node_modules/.bin/jest --coverage && yarn run badge",
54
- "testone": "jest",
55
- "badge": "make-coverage-badge --output-path ./coverage.svg",
56
- "prepublishOnly": "npm run test && npm run build && npm run build:deno",
57
- "play": "nodemon -e ts -w . -x ts-node src/playground.ts --project tsconfig.json --trace-warnings",
58
- "depcruise": "depcruise -c .dependency-cruiser.js src",
59
- "benchmark": "ts-node src/benchmarks/index.ts"
20
+ "license": "MIT",
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"
58
+ ]
59
+ },
60
+ "repository": {
61
+ "type": "git",
62
+ "url": "git+https://github.com/colinhacks/zod.git"
60
63
  },
61
- "devDependencies": {
62
- "@rollup/plugin-typescript": "^8.2.0",
63
- "@types/benchmark": "^2.1.0",
64
- "@types/jest": "^26.0.17",
65
- "@types/node": "^14.14.10",
66
- "@typescript-eslint/eslint-plugin": "^4.11.1",
67
- "@typescript-eslint/parser": "^4.11.1",
68
- "benchmark": "^2.1.4",
69
- "dependency-cruiser": "^9.19.0",
70
- "eslint": "^7.15.0",
71
- "eslint-config-prettier": "^7.1.0",
72
- "eslint-plugin-import": "^2.22.1",
73
- "eslint-plugin-simple-import-sort": "^7.0.0",
74
- "eslint-plugin-unused-imports": "^1.1.0",
75
- "husky": "^4.3.4",
76
- "jest": "^26.6.3",
77
- "lint-staged": "^10.5.3",
78
- "make-coverage-badge": "^1.2.0",
79
- "nodemon": "^2.0.2",
80
- "prettier": "^2.2.1",
81
- "rollup": "^2.42.1",
82
- "ts-jest": "^26.4.4",
83
- "ts-node": "^9.1.0",
84
- "tslib": "^2.1.0",
85
- "typescript": "^4.3.2"
64
+ "bugs": {
65
+ "url": "https://github.com/colinhacks/zod/issues"
86
66
  },
87
- "husky": {
88
- "hooks": {
89
- "pre-commit": "lint-staged && yarn build:deno && git add .",
90
- "pre-push": "lint-staged && yarn build && yarn test"
67
+ "support": {
68
+ "backing": {
69
+ "npm-funding": true
91
70
  }
92
71
  },
93
- "lint-staged": {
94
- "*.ts": [
95
- "yarn fix:lint",
96
- "yarn fix:format"
97
- ]
72
+ "dependencies": {
73
+ "@zod/core": "0.1.2"
98
74
  },
99
- "dependencies": {}
100
- }
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
+ "bump:beta": "pnpm version v4.0.0-beta.$(date +%Y%m%dT%H%M%S)",
82
+ "pub:beta": "pnpm bump:beta && pnpm publish --tag next --publish-branch v4 --no-git-checks"
83
+ }
84
+ }
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,52 @@
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.treeifyError(err)` function instead. */
9
+ format(): core.$ZodFormattedError<T>;
10
+ /** @deprecated Use the `z.treeifyError(err)` function instead. */
11
+ format<U>(mapper: (issue: core.$ZodIssue) => U): core.$ZodFormattedError<T, U>;
12
+ format(mapper?: AnyFunc): any {
13
+ return core.formatError(this, mapper);
14
+ }
15
+
16
+ /** @deprecated Use the `z.treeifyError(err)` function instead. */
17
+ flatten(): core.$ZodFlattenedError<T>;
18
+ /** @deprecated Use the `z.treeifyError(err)` function instead. */
19
+ flatten<U>(mapper: (issue: core.$ZodIssue) => U): core.$ZodFlattenedError<T, U>;
20
+ flatten(mapper?: AnyFunc): core.$ZodFlattenedError<T> {
21
+ return core.flattenError(this, mapper);
22
+ }
23
+
24
+ /** @deprecated Push directly to `.issues` instead. */
25
+ addIssue(issue: core.$ZodIssue): void {
26
+ this.issues.push(issue);
27
+ }
28
+ /** @deprecated Push directly to `.issues` instead. */
29
+ addIssues(issues: core.$ZodIssue[]): void {
30
+ this.issues.push(...issues);
31
+ }
32
+
33
+ /** @deprecated Check `err.issues.length === 0` instead. */
34
+ get isEmpty(): boolean {
35
+ return this.issues.length === 0;
36
+ }
37
+ }
38
+
39
+ export type {
40
+ /** @deprecated Use `z.core.$ZodFlattenedError` instead. */
41
+ $ZodFlattenedError as ZodFlattenedError,
42
+ /** @deprecated Use `z.core.$ZodFormattedError` instead. */
43
+ $ZodFormattedError as ZodFormattedError,
44
+ /** @deprecated Use `z.core.$ZodErrorMap` instead. */
45
+ $ZodErrorMap as ZodErrorMap,
46
+ } from "@zod/core";
47
+
48
+ /** @deprecated Use `z.core.$ZodRawIssue` instead. */
49
+ export type IssueData = core.$ZodRawIssue;
50
+
51
+ // /** @deprecated Use `z.core.$ZodErrorMapCtx` instead. */
52
+ // export type ErrorMapCtx = core.$ZodErrorMapCtx;
@@ -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
@@ -0,0 +1,5 @@
1
+ import * as z from "./external.js";
2
+
3
+ export { z };
4
+ export * from "./external.js";
5
+ export default z;
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;