zod 4.1.0-canary.20250821T014930 → 4.1.0-canary.20250823T071040

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 (158) hide show
  1. package/index.cjs +17 -7
  2. package/package.json +1 -1
  3. package/src/v4/classic/external.ts +0 -1
  4. package/src/v4/classic/parse.ts +49 -0
  5. package/src/v4/classic/schemas.ts +145 -7
  6. package/src/v4/classic/tests/catch.test.ts +25 -0
  7. package/src/v4/classic/tests/codec-examples.test.ts +538 -0
  8. package/src/v4/classic/tests/codec.test.ts +532 -0
  9. package/src/v4/classic/tests/continuability.test.ts +1 -1
  10. package/src/v4/classic/tests/default.test.ts +32 -0
  11. package/src/v4/classic/tests/firstparty.test.ts +4 -0
  12. package/src/v4/classic/tests/function.test.ts +31 -31
  13. package/src/v4/classic/tests/hash.test.ts +68 -0
  14. package/src/v4/classic/tests/nonoptional.test.ts +15 -0
  15. package/src/v4/classic/tests/object.test.ts +31 -0
  16. package/src/v4/classic/tests/pipe.test.ts +25 -5
  17. package/src/v4/classic/tests/prefault.test.ts +25 -0
  18. package/src/v4/classic/tests/preprocess.test.ts +1 -6
  19. package/src/v4/classic/tests/refine.test.ts +76 -3
  20. package/src/v4/classic/tests/string-formats.test.ts +16 -0
  21. package/src/v4/classic/tests/string.test.ts +82 -1
  22. package/src/v4/classic/tests/stringbool.test.ts +40 -0
  23. package/src/v4/classic/tests/template-literal.test.ts +1 -1
  24. package/src/v4/classic/tests/to-json-schema.test.ts +21 -2
  25. package/src/v4/classic/tests/transform.test.ts +7 -0
  26. package/src/v4/classic/tests/union.test.ts +1 -1
  27. package/src/v4/core/api.ts +25 -35
  28. package/src/v4/core/core.ts +7 -26
  29. package/src/v4/core/index.ts +0 -1
  30. package/src/v4/core/json-schema.ts +1 -0
  31. package/src/v4/core/parse.ts +101 -0
  32. package/src/v4/core/regexes.ts +40 -1
  33. package/src/v4/core/schemas.ts +521 -129
  34. package/src/v4/core/to-json-schema.ts +43 -8
  35. package/src/v4/core/util.ts +73 -0
  36. package/src/v4/mini/external.ts +0 -1
  37. package/src/v4/mini/parse.ts +14 -1
  38. package/src/v4/mini/schemas.ts +153 -12
  39. package/src/v4/mini/tests/codec.test.ts +499 -0
  40. package/src/v4/mini/tests/object.test.ts +9 -0
  41. package/src/v4/mini/tests/string.test.ts +16 -0
  42. package/v3/index.cjs +17 -7
  43. package/v4/classic/coerce.cjs +17 -7
  44. package/v4/classic/compat.cjs +17 -7
  45. package/v4/classic/errors.cjs +17 -7
  46. package/v4/classic/external.cjs +18 -9
  47. package/v4/classic/external.d.cts +1 -1
  48. package/v4/classic/external.d.ts +1 -1
  49. package/v4/classic/external.js +1 -1
  50. package/v4/classic/index.cjs +17 -7
  51. package/v4/classic/iso.cjs +17 -7
  52. package/v4/classic/parse.cjs +27 -8
  53. package/v4/classic/parse.d.cts +8 -0
  54. package/v4/classic/parse.d.ts +8 -0
  55. package/v4/classic/parse.js +9 -0
  56. package/v4/classic/schemas.cjs +76 -11
  57. package/v4/classic/schemas.d.cts +48 -2
  58. package/v4/classic/schemas.d.ts +48 -2
  59. package/v4/classic/schemas.js +51 -3
  60. package/v4/core/api.cjs +36 -35
  61. package/v4/core/api.d.cts +3 -4
  62. package/v4/core/api.d.ts +3 -4
  63. package/v4/core/api.js +19 -24
  64. package/v4/core/checks.cjs +17 -7
  65. package/v4/core/core.cjs +8 -1
  66. package/v4/core/core.d.cts +3 -0
  67. package/v4/core/core.d.ts +3 -0
  68. package/v4/core/core.js +6 -0
  69. package/v4/core/errors.cjs +17 -7
  70. package/v4/core/index.cjs +17 -8
  71. package/v4/core/index.d.cts +0 -1
  72. package/v4/core/index.d.ts +0 -1
  73. package/v4/core/index.js +0 -1
  74. package/v4/core/json-schema.d.cts +1 -0
  75. package/v4/core/json-schema.d.ts +1 -0
  76. package/v4/core/parse.cjs +62 -8
  77. package/v4/core/parse.d.cts +24 -0
  78. package/v4/core/parse.d.ts +24 -0
  79. package/v4/core/parse.js +36 -0
  80. package/v4/core/regexes.cjs +34 -2
  81. package/v4/core/regexes.d.cts +16 -0
  82. package/v4/core/regexes.d.ts +16 -0
  83. package/v4/core/regexes.js +32 -1
  84. package/v4/core/schemas.cjs +326 -84
  85. package/v4/core/schemas.d.cts +61 -3
  86. package/v4/core/schemas.d.ts +61 -3
  87. package/v4/core/schemas.js +308 -76
  88. package/v4/core/to-json-schema.cjs +42 -5
  89. package/v4/core/to-json-schema.d.cts +4 -3
  90. package/v4/core/to-json-schema.d.ts +4 -3
  91. package/v4/core/to-json-schema.js +42 -5
  92. package/v4/core/util.cjs +69 -0
  93. package/v4/core/util.d.cts +10 -0
  94. package/v4/core/util.d.ts +10 -0
  95. package/v4/core/util.js +62 -0
  96. package/v4/locales/ar.cjs +17 -7
  97. package/v4/locales/az.cjs +17 -7
  98. package/v4/locales/be.cjs +17 -7
  99. package/v4/locales/bg.cjs +17 -7
  100. package/v4/locales/ca.cjs +17 -7
  101. package/v4/locales/cs.cjs +17 -7
  102. package/v4/locales/da.cjs +17 -7
  103. package/v4/locales/de.cjs +17 -7
  104. package/v4/locales/en.cjs +17 -7
  105. package/v4/locales/eo.cjs +17 -7
  106. package/v4/locales/es.cjs +17 -7
  107. package/v4/locales/fa.cjs +17 -7
  108. package/v4/locales/fi.cjs +17 -7
  109. package/v4/locales/fr-CA.cjs +17 -7
  110. package/v4/locales/fr.cjs +17 -7
  111. package/v4/locales/he.cjs +17 -7
  112. package/v4/locales/hu.cjs +17 -7
  113. package/v4/locales/id.cjs +17 -7
  114. package/v4/locales/is.cjs +17 -7
  115. package/v4/locales/it.cjs +17 -7
  116. package/v4/locales/ja.cjs +17 -7
  117. package/v4/locales/kh.cjs +17 -7
  118. package/v4/locales/ko.cjs +17 -7
  119. package/v4/locales/mk.cjs +17 -7
  120. package/v4/locales/ms.cjs +17 -7
  121. package/v4/locales/nl.cjs +17 -7
  122. package/v4/locales/no.cjs +17 -7
  123. package/v4/locales/ota.cjs +17 -7
  124. package/v4/locales/pl.cjs +17 -7
  125. package/v4/locales/ps.cjs +17 -7
  126. package/v4/locales/pt.cjs +17 -7
  127. package/v4/locales/ru.cjs +17 -7
  128. package/v4/locales/sl.cjs +17 -7
  129. package/v4/locales/sv.cjs +17 -7
  130. package/v4/locales/ta.cjs +17 -7
  131. package/v4/locales/th.cjs +17 -7
  132. package/v4/locales/tr.cjs +17 -7
  133. package/v4/locales/ua.cjs +17 -7
  134. package/v4/locales/ur.cjs +17 -7
  135. package/v4/locales/vi.cjs +17 -7
  136. package/v4/locales/yo.cjs +17 -7
  137. package/v4/locales/zh-CN.cjs +17 -7
  138. package/v4/locales/zh-TW.cjs +17 -7
  139. package/v4/mini/coerce.cjs +17 -7
  140. package/v4/mini/external.cjs +18 -9
  141. package/v4/mini/external.d.cts +1 -1
  142. package/v4/mini/external.d.ts +1 -1
  143. package/v4/mini/external.js +1 -1
  144. package/v4/mini/index.cjs +17 -7
  145. package/v4/mini/iso.cjs +17 -7
  146. package/v4/mini/parse.cjs +9 -1
  147. package/v4/mini/parse.d.cts +1 -1
  148. package/v4/mini/parse.d.ts +1 -1
  149. package/v4/mini/parse.js +1 -1
  150. package/v4/mini/schemas.cjs +75 -10
  151. package/v4/mini/schemas.d.cts +49 -1
  152. package/v4/mini/schemas.d.ts +49 -1
  153. package/v4/mini/schemas.js +49 -2
  154. package/src/v4/core/function.ts +0 -176
  155. package/v4/core/function.cjs +0 -102
  156. package/v4/core/function.d.cts +0 -52
  157. package/v4/core/function.d.ts +0 -52
  158. package/v4/core/function.js +0 -75
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
26
36
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
27
37
  };
@@ -29,7 +39,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
29
39
  return (mod && mod.__esModule) ? mod : { "default": mod };
30
40
  };
31
41
  Object.defineProperty(exports, "__esModule", { value: true });
32
- exports.coerce = exports.iso = exports.ZodISODuration = exports.ZodISOTime = exports.ZodISODate = exports.ZodISODateTime = exports.locales = exports.NEVER = exports.TimePrecision = exports.toJSONSchema = exports.flattenError = exports.formatError = exports.prettifyError = exports.treeifyError = exports.regexes = exports.clone = exports.$brand = exports.$input = exports.$output = exports.function = exports.config = exports.registry = exports.globalRegistry = exports.core = void 0;
42
+ exports.coerce = exports.iso = exports.ZodISODuration = exports.ZodISOTime = exports.ZodISODate = exports.ZodISODateTime = exports.locales = exports.NEVER = exports.TimePrecision = exports.toJSONSchema = exports.flattenError = exports.formatError = exports.prettifyError = exports.treeifyError = exports.regexes = exports.clone = exports.$brand = exports.$input = exports.$output = exports.config = exports.registry = exports.globalRegistry = exports.core = void 0;
33
43
  exports.core = __importStar(require("../core/index.cjs"));
34
44
  __exportStar(require("./schemas.cjs"), exports);
35
45
  __exportStar(require("./checks.cjs"), exports);
@@ -44,7 +54,6 @@ var index_js_2 = require("../core/index.cjs");
44
54
  Object.defineProperty(exports, "globalRegistry", { enumerable: true, get: function () { return index_js_2.globalRegistry; } });
45
55
  Object.defineProperty(exports, "registry", { enumerable: true, get: function () { return index_js_2.registry; } });
46
56
  Object.defineProperty(exports, "config", { enumerable: true, get: function () { return index_js_2.config; } });
47
- Object.defineProperty(exports, "function", { enumerable: true, get: function () { return index_js_2.function; } });
48
57
  Object.defineProperty(exports, "$output", { enumerable: true, get: function () { return index_js_2.$output; } });
49
58
  Object.defineProperty(exports, "$input", { enumerable: true, get: function () { return index_js_2.$input; } });
50
59
  Object.defineProperty(exports, "$brand", { enumerable: true, get: function () { return index_js_2.$brand; } });
@@ -5,7 +5,7 @@ export * from "./errors.cjs";
5
5
  export * from "./parse.cjs";
6
6
  export * from "./compat.cjs";
7
7
  export type { infer, output, input } from "../core/index.cjs";
8
- export { globalRegistry, type GlobalMeta, registry, config, function, $output, $input, $brand, clone, regexes, treeifyError, prettifyError, formatError, flattenError, toJSONSchema, TimePrecision, NEVER, } from "../core/index.cjs";
8
+ export { globalRegistry, type GlobalMeta, registry, config, $output, $input, $brand, clone, regexes, treeifyError, prettifyError, formatError, flattenError, toJSONSchema, TimePrecision, NEVER, } from "../core/index.cjs";
9
9
  export * as locales from "../locales/index.cjs";
10
10
  export { ZodISODateTime, ZodISODate, ZodISOTime, ZodISODuration } from "./iso.cjs";
11
11
  export * as iso from "./iso.cjs";
@@ -5,7 +5,7 @@ export * from "./errors.js";
5
5
  export * from "./parse.js";
6
6
  export * from "./compat.js";
7
7
  export type { infer, output, input } from "../core/index.js";
8
- export { globalRegistry, type GlobalMeta, registry, config, function, $output, $input, $brand, clone, regexes, treeifyError, prettifyError, formatError, flattenError, toJSONSchema, TimePrecision, NEVER, } from "../core/index.js";
8
+ export { globalRegistry, type GlobalMeta, registry, config, $output, $input, $brand, clone, regexes, treeifyError, prettifyError, formatError, flattenError, toJSONSchema, TimePrecision, NEVER, } from "../core/index.js";
9
9
  export * as locales from "../locales/index.js";
10
10
  export { ZodISODateTime, ZodISODate, ZodISOTime, ZodISODuration } from "./iso.js";
11
11
  export * as iso from "./iso.js";
@@ -8,7 +8,7 @@ export * from "./compat.js";
8
8
  import { config } from "../core/index.js";
9
9
  import en from "../locales/en.js";
10
10
  config(en());
11
- export { globalRegistry, registry, config, function, $output, $input, $brand, clone, regexes, treeifyError, prettifyError, formatError, flattenError, toJSONSchema, TimePrecision, NEVER, } from "../core/index.js";
11
+ export { globalRegistry, registry, config, $output, $input, $brand, clone, regexes, treeifyError, prettifyError, formatError, flattenError, toJSONSchema, TimePrecision, NEVER, } from "../core/index.js";
12
12
  export * as locales from "../locales/index.js";
13
13
  // iso
14
14
  // must be exported from top-level
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
26
36
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
27
37
  };
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
36
  exports.ZodISODuration = exports.ZodISOTime = exports.ZodISODate = exports.ZodISODateTime = void 0;
27
37
  exports.datetime = datetime;
@@ -15,18 +15,37 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.safeParseAsync = exports.safeParse = exports.parseAsync = exports.parse = void 0;
36
+ exports.safeDecodeAsync = exports.safeEncodeAsync = exports.safeDecode = exports.safeEncode = exports.decodeAsync = exports.encodeAsync = exports.decode = exports.encode = exports.safeParseAsync = exports.safeParse = exports.parseAsync = exports.parse = void 0;
27
37
  const core = __importStar(require("../core/index.cjs"));
28
38
  const errors_js_1 = require("./errors.cjs");
29
39
  exports.parse = core._parse(errors_js_1.ZodRealError);
30
40
  exports.parseAsync = core._parseAsync(errors_js_1.ZodRealError);
31
41
  exports.safeParse = core._safeParse(errors_js_1.ZodRealError);
32
42
  exports.safeParseAsync = core._safeParseAsync(errors_js_1.ZodRealError);
43
+ // Codec functions
44
+ exports.encode = core._encode(errors_js_1.ZodRealError);
45
+ exports.decode = core._decode(errors_js_1.ZodRealError);
46
+ exports.encodeAsync = core._encodeAsync(errors_js_1.ZodRealError);
47
+ exports.decodeAsync = core._decodeAsync(errors_js_1.ZodRealError);
48
+ exports.safeEncode = core._safeEncode(errors_js_1.ZodRealError);
49
+ exports.safeDecode = core._safeDecode(errors_js_1.ZodRealError);
50
+ exports.safeEncodeAsync = core._safeEncodeAsync(errors_js_1.ZodRealError);
51
+ exports.safeDecodeAsync = core._safeDecodeAsync(errors_js_1.ZodRealError);
@@ -21,3 +21,11 @@ export declare const parseAsync: <T extends core.$ZodType>(schema: T, value: unk
21
21
  }) => Promise<core.output<T>>;
22
22
  export declare const safeParse: <T extends core.$ZodType>(schema: T, value: unknown, _ctx?: core.ParseContext<core.$ZodIssue>) => ZodSafeParseResult<core.output<T>>;
23
23
  export declare const safeParseAsync: <T extends core.$ZodType>(schema: T, value: unknown, _ctx?: core.ParseContext<core.$ZodIssue>) => Promise<ZodSafeParseResult<core.output<T>>>;
24
+ export declare const encode: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?: core.ParseContext<core.$ZodIssue>) => core.input<T>;
25
+ export declare const decode: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?: core.ParseContext<core.$ZodIssue>) => core.output<T>;
26
+ export declare const encodeAsync: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?: core.ParseContext<core.$ZodIssue>) => Promise<core.input<T>>;
27
+ export declare const decodeAsync: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?: core.ParseContext<core.$ZodIssue>) => Promise<core.output<T>>;
28
+ export declare const safeEncode: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?: core.ParseContext<core.$ZodIssue>) => ZodSafeParseResult<core.input<T>>;
29
+ export declare const safeDecode: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?: core.ParseContext<core.$ZodIssue>) => ZodSafeParseResult<core.output<T>>;
30
+ export declare const safeEncodeAsync: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?: core.ParseContext<core.$ZodIssue>) => Promise<ZodSafeParseResult<core.input<T>>>;
31
+ export declare const safeDecodeAsync: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?: core.ParseContext<core.$ZodIssue>) => Promise<ZodSafeParseResult<core.output<T>>>;
@@ -21,3 +21,11 @@ export declare const parseAsync: <T extends core.$ZodType>(schema: T, value: unk
21
21
  }) => Promise<core.output<T>>;
22
22
  export declare const safeParse: <T extends core.$ZodType>(schema: T, value: unknown, _ctx?: core.ParseContext<core.$ZodIssue>) => ZodSafeParseResult<core.output<T>>;
23
23
  export declare const safeParseAsync: <T extends core.$ZodType>(schema: T, value: unknown, _ctx?: core.ParseContext<core.$ZodIssue>) => Promise<ZodSafeParseResult<core.output<T>>>;
24
+ export declare const encode: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?: core.ParseContext<core.$ZodIssue>) => core.input<T>;
25
+ export declare const decode: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?: core.ParseContext<core.$ZodIssue>) => core.output<T>;
26
+ export declare const encodeAsync: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?: core.ParseContext<core.$ZodIssue>) => Promise<core.input<T>>;
27
+ export declare const decodeAsync: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?: core.ParseContext<core.$ZodIssue>) => Promise<core.output<T>>;
28
+ export declare const safeEncode: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?: core.ParseContext<core.$ZodIssue>) => ZodSafeParseResult<core.input<T>>;
29
+ export declare const safeDecode: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?: core.ParseContext<core.$ZodIssue>) => ZodSafeParseResult<core.output<T>>;
30
+ export declare const safeEncodeAsync: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?: core.ParseContext<core.$ZodIssue>) => Promise<ZodSafeParseResult<core.input<T>>>;
31
+ export declare const safeDecodeAsync: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?: core.ParseContext<core.$ZodIssue>) => Promise<ZodSafeParseResult<core.output<T>>>;
@@ -4,3 +4,12 @@ export const parse = /* @__PURE__ */ core._parse(ZodRealError);
4
4
  export const parseAsync = /* @__PURE__ */ core._parseAsync(ZodRealError);
5
5
  export const safeParse = /* @__PURE__ */ core._safeParse(ZodRealError);
6
6
  export const safeParseAsync = /* @__PURE__ */ core._safeParseAsync(ZodRealError);
7
+ // Codec functions
8
+ export const encode = /* @__PURE__ */ core._encode(ZodRealError);
9
+ export const decode = /* @__PURE__ */ core._decode(ZodRealError);
10
+ export const encodeAsync = /* @__PURE__ */ core._encodeAsync(ZodRealError);
11
+ export const decodeAsync = /* @__PURE__ */ core._decodeAsync(ZodRealError);
12
+ export const safeEncode = /* @__PURE__ */ core._safeEncode(ZodRealError);
13
+ export const safeDecode = /* @__PURE__ */ core._safeDecode(ZodRealError);
14
+ export const safeEncodeAsync = /* @__PURE__ */ core._safeEncodeAsync(ZodRealError);
15
+ export const safeDecodeAsync = /* @__PURE__ */ core._safeDecodeAsync(ZodRealError);
@@ -15,16 +15,26 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
36
  exports.ZodTransform = 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.ZodCustomStringFormat = 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 = 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.ZodPrefault = exports.ZodDefault = exports.ZodNullable = exports.ZodOptional = void 0;
37
+ exports.stringbool = exports.ZodCustom = exports.ZodFunction = exports.ZodPromise = exports.ZodLazy = exports.ZodTemplateLiteral = exports.ZodReadonly = exports.ZodCodec = exports.ZodPipe = exports.ZodNaN = exports.ZodCatch = exports.ZodSuccess = exports.ZodNonOptional = exports.ZodPrefault = exports.ZodDefault = exports.ZodNullable = exports.ZodOptional = void 0;
28
38
  exports.string = string;
29
39
  exports.email = email;
30
40
  exports.guid = guid;
@@ -33,6 +43,7 @@ exports.uuidv4 = uuidv4;
33
43
  exports.uuidv6 = uuidv6;
34
44
  exports.uuidv7 = uuidv7;
35
45
  exports.url = url;
46
+ exports.httpUrl = httpUrl;
36
47
  exports.emoji = emoji;
37
48
  exports.nanoid = nanoid;
38
49
  exports.cuid = cuid;
@@ -50,6 +61,8 @@ exports.e164 = e164;
50
61
  exports.jwt = jwt;
51
62
  exports.stringFormat = stringFormat;
52
63
  exports.hostname = hostname;
64
+ exports.hex = hex;
65
+ exports.hash = hash;
53
66
  exports.number = number;
54
67
  exports.int = int;
55
68
  exports.float32 = float32;
@@ -96,10 +109,15 @@ exports.success = success;
96
109
  exports.catch = _catch;
97
110
  exports.nan = nan;
98
111
  exports.pipe = pipe;
112
+ exports.codec = codec;
99
113
  exports.readonly = readonly;
100
114
  exports.templateLiteral = templateLiteral;
101
115
  exports.lazy = lazy;
102
116
  exports.promise = promise;
117
+ exports._function = _function;
118
+ exports.function = _function;
119
+ exports._function = _function;
120
+ exports.function = _function;
103
121
  exports.check = check;
104
122
  exports.custom = custom;
105
123
  exports.refine = refine;
@@ -292,6 +310,13 @@ exports.ZodURL = core.$constructor("ZodURL", (inst, def) => {
292
310
  function url(params) {
293
311
  return core._url(exports.ZodURL, params);
294
312
  }
313
+ function httpUrl(params) {
314
+ return core._url(exports.ZodURL, {
315
+ protocol: /^https?$/,
316
+ hostname: core.regexes.domain,
317
+ ...index_js_1.util.normalizeParams(params),
318
+ });
319
+ }
295
320
  exports.ZodEmoji = core.$constructor("ZodEmoji", (inst, def) => {
296
321
  // ZodStringFormat.init(inst, def);
297
322
  core.$ZodEmoji.init(inst, def);
@@ -421,6 +446,17 @@ function stringFormat(format, fnOrRegex, _params = {}) {
421
446
  function hostname(_params) {
422
447
  return core._stringFormat(exports.ZodCustomStringFormat, "hostname", core.regexes.hostname, _params);
423
448
  }
449
+ function hex(_params) {
450
+ return core._stringFormat(exports.ZodCustomStringFormat, "hex", core.regexes.hex, _params);
451
+ }
452
+ function hash(alg, params) {
453
+ const enc = params?.enc ?? "hex";
454
+ const format = `${alg}_${enc}`;
455
+ const regex = core.regexes[format];
456
+ if (!regex)
457
+ throw new Error(`Unrecognized hash format: ${format}`);
458
+ return core._stringFormat(exports.ZodCustomStringFormat, format, regex, params);
459
+ }
424
460
  exports.ZodNumber = core.$constructor("ZodNumber", (inst, def) => {
425
461
  core.$ZodNumber.init(inst, def);
426
462
  exports.ZodType.init(inst, def);
@@ -594,7 +630,7 @@ function keyof(schema) {
594
630
  return _enum(Object.keys(shape));
595
631
  }
596
632
  exports.ZodObject = core.$constructor("ZodObject", (inst, def) => {
597
- core.$ZodObject.init(inst, def);
633
+ core.$ZodObjectJIT.init(inst, def);
598
634
  exports.ZodType.init(inst, def);
599
635
  index_js_1.util.defineLazy(inst, "shape", () => def.shape);
600
636
  inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
@@ -606,6 +642,9 @@ exports.ZodObject = core.$constructor("ZodObject", (inst, def) => {
606
642
  inst.extend = (incoming) => {
607
643
  return index_js_1.util.extend(inst, incoming);
608
644
  };
645
+ inst.safeExtend = (incoming) => {
646
+ return index_js_1.util.safeExtend(inst, incoming);
647
+ };
609
648
  inst.merge = (other) => index_js_1.util.merge(inst, other);
610
649
  inst.pick = (mask) => index_js_1.util.pick(inst, mask);
611
650
  inst.omit = (mask) => index_js_1.util.omit(inst, mask);
@@ -851,6 +890,9 @@ exports.ZodTransform = core.$constructor("ZodTransform", (inst, def) => {
851
890
  core.$ZodTransform.init(inst, def);
852
891
  exports.ZodType.init(inst, def);
853
892
  inst._zod.parse = (payload, _ctx) => {
893
+ if (_ctx.direction === "backward") {
894
+ throw new core.$ZodEncodeError(inst.constructor.name);
895
+ }
854
896
  payload.addIssue = (issue) => {
855
897
  if (typeof issue === "string") {
856
898
  payload.issues.push(index_js_1.util.issue(issue, payload.value, def));
@@ -996,6 +1038,19 @@ function pipe(in_, out) {
996
1038
  // ...util.normalizeParams(params),
997
1039
  });
998
1040
  }
1041
+ exports.ZodCodec = core.$constructor("ZodCodec", (inst, def) => {
1042
+ exports.ZodPipe.init(inst, def);
1043
+ core.$ZodCodec.init(inst, def);
1044
+ });
1045
+ function codec(in_, out, params) {
1046
+ return new exports.ZodCodec({
1047
+ type: "pipe",
1048
+ in: in_,
1049
+ out: out,
1050
+ transform: params.decode,
1051
+ reverseTransform: params.encode,
1052
+ });
1053
+ }
999
1054
  exports.ZodReadonly = core.$constructor("ZodReadonly", (inst, def) => {
1000
1055
  core.$ZodReadonly.init(inst, def);
1001
1056
  exports.ZodType.init(inst, def);
@@ -1040,6 +1095,17 @@ function promise(innerType) {
1040
1095
  innerType: innerType,
1041
1096
  });
1042
1097
  }
1098
+ exports.ZodFunction = core.$constructor("ZodFunction", (inst, def) => {
1099
+ core.$ZodFunction.init(inst, def);
1100
+ exports.ZodType.init(inst, def);
1101
+ });
1102
+ function _function(params) {
1103
+ return new exports.ZodFunction({
1104
+ type: "function",
1105
+ input: Array.isArray(params?.input) ? tuple(params?.input) : (params?.input ?? array(unknown())),
1106
+ output: params?.output ?? unknown(),
1107
+ });
1108
+ }
1043
1109
  exports.ZodCustom = core.$constructor("ZodCustom", (inst, def) => {
1044
1110
  core.$ZodCustom.init(inst, def);
1045
1111
  exports.ZodType.init(inst, def);
@@ -1078,10 +1144,9 @@ function _instanceof(cls, params = {
1078
1144
  }
1079
1145
  // stringbool
1080
1146
  const stringbool = (...args) => core._stringbool({
1081
- Pipe: exports.ZodPipe,
1147
+ Codec: exports.ZodCodec,
1082
1148
  Boolean: exports.ZodBoolean,
1083
1149
  String: exports.ZodString,
1084
- Transform: exports.ZodTransform,
1085
1150
  }, ...args);
1086
1151
  exports.stringbool = stringbool;
1087
1152
  function json(params) {
@@ -174,6 +174,7 @@ export interface ZodURL extends ZodStringFormat<"url"> {
174
174
  }
175
175
  export declare const ZodURL: core.$constructor<ZodURL>;
176
176
  export declare function url(params?: string | core.$ZodURLParams): ZodURL;
177
+ export declare function httpUrl(params?: string | Omit<core.$ZodURLParams, "protocol" | "hostname">): ZodURL;
177
178
  export interface ZodEmoji extends ZodStringFormat<"emoji"> {
178
179
  _zod: core.$ZodEmojiInternals;
179
180
  }
@@ -255,6 +256,10 @@ export interface ZodCustomStringFormat<Format extends string = string> extends Z
255
256
  export declare const ZodCustomStringFormat: core.$constructor<ZodCustomStringFormat>;
256
257
  export declare function stringFormat<Format extends string>(format: Format, fnOrRegex: ((arg: string) => util.MaybeAsync<unknown>) | RegExp, _params?: string | core.$ZodStringFormatParams): ZodCustomStringFormat<Format>;
257
258
  export declare function hostname(_params?: string | core.$ZodStringFormatParams): ZodCustomStringFormat<"hostname">;
259
+ export declare function hex(_params?: string | core.$ZodStringFormatParams): ZodCustomStringFormat<"hex">;
260
+ export declare function hash<Alg extends util.HashAlgorithm, Enc extends util.HashEncoding = "hex">(alg: Alg, params?: {
261
+ enc?: Enc;
262
+ } & core.$ZodStringFormatParams): ZodCustomStringFormat<`${Alg}_${Enc}`>;
258
263
  export interface _ZodNumber<Internals extends core.$ZodNumberInternals = core.$ZodNumberInternals> extends _ZodType<Internals> {
259
264
  gt(value: number, params?: string | core.$ZodCheckGreaterThanParams): this;
260
265
  /** Identical to .min() */
@@ -396,6 +401,9 @@ export interface ZodArray<T extends core.SomeType = core.$ZodType> extends _ZodT
396
401
  export declare const ZodArray: core.$constructor<ZodArray>;
397
402
  export declare function array<T extends core.SomeType>(element: T, params?: string | core.$ZodArrayParams): ZodArray<T>;
398
403
  export declare function keyof<T extends ZodObject>(schema: T): ZodEnum<util.KeysEnum<T["_zod"]["output"]>>;
404
+ export type SafeExtendShape<Base extends core.$ZodShape, Ext extends core.$ZodLooseShape> = {
405
+ [K in keyof Ext]: K extends keyof Base ? core.output<Ext[K]> extends core.output<Base[K]> ? core.input<Ext[K]> extends core.input<Base[K]> ? Ext[K] : never : never : Ext[K];
406
+ };
399
407
  export interface ZodObject<
400
408
  /** @ts-ignore Cast variance */
401
409
  out Shape extends core.$ZodShape = core.$ZodLooseShape, out Config extends core.$ZodObjectConfig = core.$strip> extends _ZodType<core.$ZodObjectInternals<Shape, Config>>, core.$ZodObject<Shape, Config> {
@@ -412,6 +420,7 @@ out Shape extends core.$ZodShape = core.$ZodLooseShape, out Config extends core.
412
420
  /** This is the default behavior. This method call is likely unnecessary. */
413
421
  strip(): ZodObject<Shape, core.$strip>;
414
422
  extend<U extends core.$ZodLooseShape>(shape: U): ZodObject<util.Extend<Shape, U>, Config>;
423
+ safeExtend<U extends core.$ZodLooseShape>(shape: SafeExtendShape<Shape, U> & Partial<Record<keyof Shape, core.SomeType>>): ZodObject<util.Extend<Shape, U>, Config>;
415
424
  /**
416
425
  * @deprecated Use [`A.extend(B.shape)`](https://zod.dev/api?id=extend) instead.
417
426
  */
@@ -472,7 +481,6 @@ export declare const ZodMap: core.$constructor<ZodMap>;
472
481
  export declare function map<Key extends core.SomeType, Value extends core.SomeType>(keyType: Key, valueType: Value, params?: string | core.$ZodMapParams): ZodMap<Key, Value>;
473
482
  export interface ZodSet<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodSetInternals<T>>, core.$ZodSet<T> {
474
483
  min(minSize: number, params?: string | core.$ZodCheckMinSizeParams): this;
475
- /** */
476
484
  nonempty(params?: string | core.$ZodCheckMinSizeParams): this;
477
485
  max(maxSize: number, params?: string | core.$ZodCheckMaxSizeParams): this;
478
486
  size(size: number, params?: string | core.$ZodCheckSizeEqualsParams): this;
@@ -569,6 +577,15 @@ export interface ZodPipe<A extends core.SomeType = core.$ZodType, B extends core
569
577
  }
570
578
  export declare const ZodPipe: core.$constructor<ZodPipe>;
571
579
  export declare function pipe<const A extends core.SomeType, B extends core.$ZodType<unknown, core.output<A>> = core.$ZodType<unknown, core.output<A>>>(in_: A, out: B | core.$ZodType<unknown, core.output<A>>): ZodPipe<A, B>;
580
+ export interface ZodCodec<A extends core.SomeType = core.$ZodType, B extends core.SomeType = core.$ZodType> extends ZodPipe<A, B>, core.$ZodCodec<A, B> {
581
+ _zod: core.$ZodCodecInternals<A, B>;
582
+ def: core.$ZodCodecDef<A, B>;
583
+ }
584
+ export declare const ZodCodec: core.$constructor<ZodCodec>;
585
+ export declare function codec<const A extends core.SomeType, B extends core.SomeType = core.$ZodType>(in_: A, out: B, params: {
586
+ decode: (value: core.output<A>, payload: core.ParsePayload<core.output<A>>) => core.input<B>;
587
+ encode: (value: core.input<B>, payload: core.ParsePayload<core.input<B>>) => core.output<A>;
588
+ }): ZodCodec<A, B>;
572
589
  export interface ZodReadonly<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodReadonlyInternals<T>>, core.$ZodReadonly<T> {
573
590
  unwrap(): T;
574
591
  }
@@ -588,6 +605,35 @@ export interface ZodPromise<T extends core.SomeType = core.$ZodType> extends _Zo
588
605
  }
589
606
  export declare const ZodPromise: core.$constructor<ZodPromise>;
590
607
  export declare function promise<T extends core.SomeType>(innerType: T): ZodPromise<T>;
608
+ export interface ZodFunction<Args extends core.$ZodFunctionIn = core.$ZodFunctionIn, Returns extends core.$ZodFunctionOut = core.$ZodFunctionOut> extends _ZodType<core.$ZodFunctionInternals<Args, Returns>>, core.$ZodFunction<Args, Returns> {
609
+ _def: core.$ZodFunctionDef<Args, Returns>;
610
+ _input: core.$InferInnerFunctionType<Args, Returns>;
611
+ _output: core.$InferOuterFunctionType<Args, Returns>;
612
+ input<const Items extends util.TupleItems, const Rest extends core.$ZodFunctionOut = core.$ZodFunctionOut>(args: Items, rest?: Rest): ZodFunction<core.$ZodTuple<Items, Rest>, Returns>;
613
+ input<NewArgs extends core.$ZodFunctionIn>(args: NewArgs): ZodFunction<NewArgs, Returns>;
614
+ input(...args: any[]): ZodFunction<any, Returns>;
615
+ output<NewReturns extends core.$ZodType>(output: NewReturns): ZodFunction<Args, NewReturns>;
616
+ }
617
+ export declare const ZodFunction: core.$constructor<ZodFunction>;
618
+ export declare function _function(): ZodFunction;
619
+ export declare function _function<const In extends Array<core.$ZodType> = Array<core.$ZodType>>(params: {
620
+ input: In;
621
+ }): ZodFunction<ZodTuple<In, null>, core.$ZodFunctionOut>;
622
+ export declare function _function<const In extends Array<core.$ZodType> = Array<core.$ZodType>, const Out extends core.$ZodFunctionOut = core.$ZodFunctionOut>(params: {
623
+ input: In;
624
+ output: Out;
625
+ }): ZodFunction<ZodTuple<In, null>, Out>;
626
+ export declare function _function<const In extends core.$ZodFunctionIn = core.$ZodFunctionIn>(params: {
627
+ input: In;
628
+ }): ZodFunction<In, core.$ZodFunctionOut>;
629
+ export declare function _function<const Out extends core.$ZodFunctionOut = core.$ZodFunctionOut>(params: {
630
+ output: Out;
631
+ }): ZodFunction<core.$ZodFunctionIn, Out>;
632
+ export declare function _function<In extends core.$ZodFunctionIn = core.$ZodFunctionIn, Out extends core.$ZodType = core.$ZodType>(params?: {
633
+ input: In;
634
+ output: Out;
635
+ }): ZodFunction<In, Out>;
636
+ export { _function as function };
591
637
  export interface ZodCustom<O = unknown, I = unknown> extends _ZodType<core.$ZodCustomInternals<O, I>>, core.$ZodCustom<O, I> {
592
638
  }
593
639
  export declare const ZodCustom: core.$constructor<ZodCustom>;
@@ -598,7 +644,7 @@ export declare function superRefine<T>(fn: (arg: T, payload: core.$RefinementCtx
598
644
  type ZodInstanceOfParams = core.Params<ZodCustom, core.$ZodIssueCustom, "type" | "check" | "checks" | "fn" | "abort" | "error" | "params" | "path">;
599
645
  declare function _instanceof<T extends typeof util.Class>(cls: T, params?: ZodInstanceOfParams): ZodCustom<InstanceType<T>, InstanceType<T>>;
600
646
  export { _instanceof as instanceof };
601
- export declare const stringbool: (_params?: string | core.$ZodStringBoolParams) => ZodPipe<ZodPipe<ZodString, ZodTransform<boolean, string>>, ZodBoolean>;
647
+ export declare const stringbool: (_params?: string | core.$ZodStringBoolParams) => ZodCodec<ZodString, ZodBoolean>;
602
648
  type _ZodJSONSchema = ZodUnion<[
603
649
  ZodString,
604
650
  ZodNumber,
@@ -174,6 +174,7 @@ export interface ZodURL extends ZodStringFormat<"url"> {
174
174
  }
175
175
  export declare const ZodURL: core.$constructor<ZodURL>;
176
176
  export declare function url(params?: string | core.$ZodURLParams): ZodURL;
177
+ export declare function httpUrl(params?: string | Omit<core.$ZodURLParams, "protocol" | "hostname">): ZodURL;
177
178
  export interface ZodEmoji extends ZodStringFormat<"emoji"> {
178
179
  _zod: core.$ZodEmojiInternals;
179
180
  }
@@ -255,6 +256,10 @@ export interface ZodCustomStringFormat<Format extends string = string> extends Z
255
256
  export declare const ZodCustomStringFormat: core.$constructor<ZodCustomStringFormat>;
256
257
  export declare function stringFormat<Format extends string>(format: Format, fnOrRegex: ((arg: string) => util.MaybeAsync<unknown>) | RegExp, _params?: string | core.$ZodStringFormatParams): ZodCustomStringFormat<Format>;
257
258
  export declare function hostname(_params?: string | core.$ZodStringFormatParams): ZodCustomStringFormat<"hostname">;
259
+ export declare function hex(_params?: string | core.$ZodStringFormatParams): ZodCustomStringFormat<"hex">;
260
+ export declare function hash<Alg extends util.HashAlgorithm, Enc extends util.HashEncoding = "hex">(alg: Alg, params?: {
261
+ enc?: Enc;
262
+ } & core.$ZodStringFormatParams): ZodCustomStringFormat<`${Alg}_${Enc}`>;
258
263
  export interface _ZodNumber<Internals extends core.$ZodNumberInternals = core.$ZodNumberInternals> extends _ZodType<Internals> {
259
264
  gt(value: number, params?: string | core.$ZodCheckGreaterThanParams): this;
260
265
  /** Identical to .min() */
@@ -396,6 +401,9 @@ export interface ZodArray<T extends core.SomeType = core.$ZodType> extends _ZodT
396
401
  export declare const ZodArray: core.$constructor<ZodArray>;
397
402
  export declare function array<T extends core.SomeType>(element: T, params?: string | core.$ZodArrayParams): ZodArray<T>;
398
403
  export declare function keyof<T extends ZodObject>(schema: T): ZodEnum<util.KeysEnum<T["_zod"]["output"]>>;
404
+ export type SafeExtendShape<Base extends core.$ZodShape, Ext extends core.$ZodLooseShape> = {
405
+ [K in keyof Ext]: K extends keyof Base ? core.output<Ext[K]> extends core.output<Base[K]> ? core.input<Ext[K]> extends core.input<Base[K]> ? Ext[K] : never : never : Ext[K];
406
+ };
399
407
  export interface ZodObject<
400
408
  /** @ts-ignore Cast variance */
401
409
  out Shape extends core.$ZodShape = core.$ZodLooseShape, out Config extends core.$ZodObjectConfig = core.$strip> extends _ZodType<core.$ZodObjectInternals<Shape, Config>>, core.$ZodObject<Shape, Config> {
@@ -412,6 +420,7 @@ out Shape extends core.$ZodShape = core.$ZodLooseShape, out Config extends core.
412
420
  /** This is the default behavior. This method call is likely unnecessary. */
413
421
  strip(): ZodObject<Shape, core.$strip>;
414
422
  extend<U extends core.$ZodLooseShape>(shape: U): ZodObject<util.Extend<Shape, U>, Config>;
423
+ safeExtend<U extends core.$ZodLooseShape>(shape: SafeExtendShape<Shape, U> & Partial<Record<keyof Shape, core.SomeType>>): ZodObject<util.Extend<Shape, U>, Config>;
415
424
  /**
416
425
  * @deprecated Use [`A.extend(B.shape)`](https://zod.dev/api?id=extend) instead.
417
426
  */
@@ -472,7 +481,6 @@ export declare const ZodMap: core.$constructor<ZodMap>;
472
481
  export declare function map<Key extends core.SomeType, Value extends core.SomeType>(keyType: Key, valueType: Value, params?: string | core.$ZodMapParams): ZodMap<Key, Value>;
473
482
  export interface ZodSet<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodSetInternals<T>>, core.$ZodSet<T> {
474
483
  min(minSize: number, params?: string | core.$ZodCheckMinSizeParams): this;
475
- /** */
476
484
  nonempty(params?: string | core.$ZodCheckMinSizeParams): this;
477
485
  max(maxSize: number, params?: string | core.$ZodCheckMaxSizeParams): this;
478
486
  size(size: number, params?: string | core.$ZodCheckSizeEqualsParams): this;
@@ -569,6 +577,15 @@ export interface ZodPipe<A extends core.SomeType = core.$ZodType, B extends core
569
577
  }
570
578
  export declare const ZodPipe: core.$constructor<ZodPipe>;
571
579
  export declare function pipe<const A extends core.SomeType, B extends core.$ZodType<unknown, core.output<A>> = core.$ZodType<unknown, core.output<A>>>(in_: A, out: B | core.$ZodType<unknown, core.output<A>>): ZodPipe<A, B>;
580
+ export interface ZodCodec<A extends core.SomeType = core.$ZodType, B extends core.SomeType = core.$ZodType> extends ZodPipe<A, B>, core.$ZodCodec<A, B> {
581
+ _zod: core.$ZodCodecInternals<A, B>;
582
+ def: core.$ZodCodecDef<A, B>;
583
+ }
584
+ export declare const ZodCodec: core.$constructor<ZodCodec>;
585
+ export declare function codec<const A extends core.SomeType, B extends core.SomeType = core.$ZodType>(in_: A, out: B, params: {
586
+ decode: (value: core.output<A>, payload: core.ParsePayload<core.output<A>>) => core.input<B>;
587
+ encode: (value: core.input<B>, payload: core.ParsePayload<core.input<B>>) => core.output<A>;
588
+ }): ZodCodec<A, B>;
572
589
  export interface ZodReadonly<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodReadonlyInternals<T>>, core.$ZodReadonly<T> {
573
590
  unwrap(): T;
574
591
  }
@@ -588,6 +605,35 @@ export interface ZodPromise<T extends core.SomeType = core.$ZodType> extends _Zo
588
605
  }
589
606
  export declare const ZodPromise: core.$constructor<ZodPromise>;
590
607
  export declare function promise<T extends core.SomeType>(innerType: T): ZodPromise<T>;
608
+ export interface ZodFunction<Args extends core.$ZodFunctionIn = core.$ZodFunctionIn, Returns extends core.$ZodFunctionOut = core.$ZodFunctionOut> extends _ZodType<core.$ZodFunctionInternals<Args, Returns>>, core.$ZodFunction<Args, Returns> {
609
+ _def: core.$ZodFunctionDef<Args, Returns>;
610
+ _input: core.$InferInnerFunctionType<Args, Returns>;
611
+ _output: core.$InferOuterFunctionType<Args, Returns>;
612
+ input<const Items extends util.TupleItems, const Rest extends core.$ZodFunctionOut = core.$ZodFunctionOut>(args: Items, rest?: Rest): ZodFunction<core.$ZodTuple<Items, Rest>, Returns>;
613
+ input<NewArgs extends core.$ZodFunctionIn>(args: NewArgs): ZodFunction<NewArgs, Returns>;
614
+ input(...args: any[]): ZodFunction<any, Returns>;
615
+ output<NewReturns extends core.$ZodType>(output: NewReturns): ZodFunction<Args, NewReturns>;
616
+ }
617
+ export declare const ZodFunction: core.$constructor<ZodFunction>;
618
+ export declare function _function(): ZodFunction;
619
+ export declare function _function<const In extends Array<core.$ZodType> = Array<core.$ZodType>>(params: {
620
+ input: In;
621
+ }): ZodFunction<ZodTuple<In, null>, core.$ZodFunctionOut>;
622
+ export declare function _function<const In extends Array<core.$ZodType> = Array<core.$ZodType>, const Out extends core.$ZodFunctionOut = core.$ZodFunctionOut>(params: {
623
+ input: In;
624
+ output: Out;
625
+ }): ZodFunction<ZodTuple<In, null>, Out>;
626
+ export declare function _function<const In extends core.$ZodFunctionIn = core.$ZodFunctionIn>(params: {
627
+ input: In;
628
+ }): ZodFunction<In, core.$ZodFunctionOut>;
629
+ export declare function _function<const Out extends core.$ZodFunctionOut = core.$ZodFunctionOut>(params: {
630
+ output: Out;
631
+ }): ZodFunction<core.$ZodFunctionIn, Out>;
632
+ export declare function _function<In extends core.$ZodFunctionIn = core.$ZodFunctionIn, Out extends core.$ZodType = core.$ZodType>(params?: {
633
+ input: In;
634
+ output: Out;
635
+ }): ZodFunction<In, Out>;
636
+ export { _function as function };
591
637
  export interface ZodCustom<O = unknown, I = unknown> extends _ZodType<core.$ZodCustomInternals<O, I>>, core.$ZodCustom<O, I> {
592
638
  }
593
639
  export declare const ZodCustom: core.$constructor<ZodCustom>;
@@ -598,7 +644,7 @@ export declare function superRefine<T>(fn: (arg: T, payload: core.$RefinementCtx
598
644
  type ZodInstanceOfParams = core.Params<ZodCustom, core.$ZodIssueCustom, "type" | "check" | "checks" | "fn" | "abort" | "error" | "params" | "path">;
599
645
  declare function _instanceof<T extends typeof util.Class>(cls: T, params?: ZodInstanceOfParams): ZodCustom<InstanceType<T>, InstanceType<T>>;
600
646
  export { _instanceof as instanceof };
601
- export declare const stringbool: (_params?: string | core.$ZodStringBoolParams) => ZodPipe<ZodPipe<ZodString, ZodTransform<boolean, string>>, ZodBoolean>;
647
+ export declare const stringbool: (_params?: string | core.$ZodStringBoolParams) => ZodCodec<ZodString, ZodBoolean>;
602
648
  type _ZodJSONSchema = ZodUnion<[
603
649
  ZodString,
604
650
  ZodNumber,