zod 3.25.39 → 3.25.41
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/cjs/v4/classic/external.js +11 -1
- package/dist/cjs/v4/classic/schemas.js +3 -5
- package/dist/cjs/v4/core/to-json-schema.js +41 -13
- package/dist/cjs/v4/mini/external.js +10 -1
- package/dist/cjs/v4/mini/schemas.js +2 -4
- package/dist/esm/v4/classic/external.js +6 -0
- package/dist/esm/v4/classic/schemas.js +1 -3
- package/dist/esm/v4/core/to-json-schema.js +41 -13
- package/dist/esm/v4/mini/external.js +5 -0
- package/dist/esm/v4/mini/schemas.js +0 -2
- package/dist/types/v4/classic/external.d.ts +4 -0
- package/dist/types/v4/classic/schemas.d.ts +1 -3
- package/dist/types/v4/core/schemas.d.ts +5 -0
- package/dist/types/v4/mini/external.d.ts +3 -0
- package/dist/types/v4/mini/schemas.d.ts +0 -2
- package/package.json +1 -1
|
@@ -29,7 +29,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
29
29
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
30
30
|
};
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
-
exports.locales = 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;
|
|
32
|
+
exports.coerce = exports.iso = exports.ZodISODuration = exports.ZodISOTime = exports.ZodISODate = exports.ZodISODateTime = exports.locales = 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;
|
|
33
33
|
exports.core = __importStar(require("zod/v4/core"));
|
|
34
34
|
__exportStar(require("./schemas.js"), exports);
|
|
35
35
|
__exportStar(require("./checks.js"), exports);
|
|
@@ -56,3 +56,13 @@ Object.defineProperty(exports, "formatError", { enumerable: true, get: function
|
|
|
56
56
|
Object.defineProperty(exports, "flattenError", { enumerable: true, get: function () { return core_2.flattenError; } });
|
|
57
57
|
Object.defineProperty(exports, "toJSONSchema", { enumerable: true, get: function () { return core_2.toJSONSchema; } });
|
|
58
58
|
Object.defineProperty(exports, "locales", { enumerable: true, get: function () { return core_2.locales; } });
|
|
59
|
+
// iso
|
|
60
|
+
// must be exported from top-level
|
|
61
|
+
// https://github.com/colinhacks/zod/issues/4491
|
|
62
|
+
var iso_js_1 = require("./iso.js");
|
|
63
|
+
Object.defineProperty(exports, "ZodISODateTime", { enumerable: true, get: function () { return iso_js_1.ZodISODateTime; } });
|
|
64
|
+
Object.defineProperty(exports, "ZodISODate", { enumerable: true, get: function () { return iso_js_1.ZodISODate; } });
|
|
65
|
+
Object.defineProperty(exports, "ZodISOTime", { enumerable: true, get: function () { return iso_js_1.ZodISOTime; } });
|
|
66
|
+
Object.defineProperty(exports, "ZodISODuration", { enumerable: true, get: function () { return iso_js_1.ZodISODuration; } });
|
|
67
|
+
exports.iso = __importStar(require("./iso.js"));
|
|
68
|
+
exports.coerce = __importStar(require("./coerce.js"));
|
|
@@ -23,8 +23,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
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.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 =
|
|
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 =
|
|
26
|
+
exports.ZodOptional = 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.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 = void 0;
|
|
28
28
|
exports.string = string;
|
|
29
29
|
exports.email = email;
|
|
30
30
|
exports.guid = guid;
|
|
@@ -110,8 +110,6 @@ const core_1 = require("zod/v4/core");
|
|
|
110
110
|
const checks = __importStar(require("./checks.js"));
|
|
111
111
|
const iso = __importStar(require("./iso.js"));
|
|
112
112
|
const parse = __importStar(require("./parse.js"));
|
|
113
|
-
exports.iso = __importStar(require("./iso.js"));
|
|
114
|
-
exports.coerce = __importStar(require("./coerce.js"));
|
|
115
113
|
exports.ZodType = core.$constructor("ZodType", (inst, def) => {
|
|
116
114
|
core.$ZodType.init(inst, def);
|
|
117
115
|
inst.def = def;
|
|
@@ -830,7 +828,7 @@ exports.ZodFile = core.$constructor("ZodFile", (inst, def) => {
|
|
|
830
828
|
exports.ZodType.init(inst, def);
|
|
831
829
|
inst.min = (size, params) => inst.check(core._minSize(size, params));
|
|
832
830
|
inst.max = (size, params) => inst.check(core._maxSize(size, params));
|
|
833
|
-
inst.mime = (types, params) => inst.check(core._mime(types, params));
|
|
831
|
+
inst.mime = (types, params) => inst.check(core._mime(Array.isArray(types) ? types : [types], params));
|
|
834
832
|
});
|
|
835
833
|
function file(params) {
|
|
836
834
|
return core._file(exports.ZodFile, params);
|
|
@@ -32,8 +32,6 @@ class JSONSchemaGenerator {
|
|
|
32
32
|
if (isCycle) {
|
|
33
33
|
seen.cycle = _params.path;
|
|
34
34
|
}
|
|
35
|
-
seen.count++;
|
|
36
|
-
// break cycle
|
|
37
35
|
return seen.schema;
|
|
38
36
|
}
|
|
39
37
|
// initialize
|
|
@@ -247,16 +245,20 @@ class JSONSchemaGenerator {
|
|
|
247
245
|
}
|
|
248
246
|
case "intersection": {
|
|
249
247
|
const json = _json;
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
248
|
+
const a = this.process(def.left, {
|
|
249
|
+
...params,
|
|
250
|
+
path: [...params.path, "allOf", 0],
|
|
251
|
+
});
|
|
252
|
+
const b = this.process(def.right, {
|
|
253
|
+
...params,
|
|
254
|
+
path: [...params.path, "allOf", 1],
|
|
255
|
+
});
|
|
256
|
+
const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
|
|
257
|
+
const allOf = [
|
|
258
|
+
...(isSimpleIntersection(a) ? a.allOf : [a]),
|
|
259
|
+
...(isSimpleIntersection(b) ? b.allOf : [b]),
|
|
259
260
|
];
|
|
261
|
+
json.allOf = allOf;
|
|
260
262
|
break;
|
|
261
263
|
}
|
|
262
264
|
case "tuple": {
|
|
@@ -360,9 +362,35 @@ class JSONSchemaGenerator {
|
|
|
360
362
|
break;
|
|
361
363
|
}
|
|
362
364
|
case "file": {
|
|
363
|
-
|
|
364
|
-
|
|
365
|
+
const json = _json;
|
|
366
|
+
const file = {
|
|
367
|
+
type: "string",
|
|
368
|
+
format: "binary",
|
|
369
|
+
contentEncoding: "binary",
|
|
370
|
+
};
|
|
371
|
+
const { minimum, maximum, mime } = schema._zod.bag;
|
|
372
|
+
if (minimum !== undefined)
|
|
373
|
+
file.minLength = minimum;
|
|
374
|
+
if (maximum !== undefined)
|
|
375
|
+
file.maxLength = maximum;
|
|
376
|
+
if (mime) {
|
|
377
|
+
if (mime.length === 1) {
|
|
378
|
+
file.contentMediaType = mime[0];
|
|
379
|
+
Object.assign(json, file);
|
|
380
|
+
}
|
|
381
|
+
else {
|
|
382
|
+
json.anyOf = mime.map((m) => {
|
|
383
|
+
const mFile = { ...file, contentMediaType: m };
|
|
384
|
+
return mFile;
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
389
|
+
Object.assign(json, file);
|
|
365
390
|
}
|
|
391
|
+
// if (this.unrepresentable === "throw") {
|
|
392
|
+
// throw new Error("File cannot be represented in JSON Schema");
|
|
393
|
+
// }
|
|
366
394
|
break;
|
|
367
395
|
}
|
|
368
396
|
case "transform": {
|
|
@@ -26,7 +26,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
26
26
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.locales = exports.toJSONSchema = exports.flattenError = exports.formatError = exports.prettifyError = exports.treeifyError = exports.regexes = exports.clone = exports.function = exports.$brand = exports.$input = exports.$output = exports.config = exports.registry = exports.globalRegistry = exports.core = void 0;
|
|
29
|
+
exports.coerce = exports.ZodMiniISODuration = exports.ZodMiniISOTime = exports.ZodMiniISODate = exports.ZodMiniISODateTime = exports.iso = exports.locales = exports.toJSONSchema = exports.flattenError = exports.formatError = exports.prettifyError = exports.treeifyError = exports.regexes = exports.clone = exports.function = exports.$brand = exports.$input = exports.$output = exports.config = exports.registry = exports.globalRegistry = exports.core = void 0;
|
|
30
30
|
exports.core = __importStar(require("zod/v4/core"));
|
|
31
31
|
__exportStar(require("./parse.js"), exports);
|
|
32
32
|
__exportStar(require("./schemas.js"), exports);
|
|
@@ -49,3 +49,12 @@ Object.defineProperty(exports, "toJSONSchema", { enumerable: true, get: function
|
|
|
49
49
|
Object.defineProperty(exports, "locales", { enumerable: true, get: function () { return core_1.locales; } });
|
|
50
50
|
/** A special constant with type `never` */
|
|
51
51
|
// export const NEVER = {} as never;
|
|
52
|
+
// iso
|
|
53
|
+
exports.iso = __importStar(require("./iso.js"));
|
|
54
|
+
var iso_js_1 = require("./iso.js");
|
|
55
|
+
Object.defineProperty(exports, "ZodMiniISODateTime", { enumerable: true, get: function () { return iso_js_1.ZodMiniISODateTime; } });
|
|
56
|
+
Object.defineProperty(exports, "ZodMiniISODate", { enumerable: true, get: function () { return iso_js_1.ZodMiniISODate; } });
|
|
57
|
+
Object.defineProperty(exports, "ZodMiniISOTime", { enumerable: true, get: function () { return iso_js_1.ZodMiniISOTime; } });
|
|
58
|
+
Object.defineProperty(exports, "ZodMiniISODuration", { enumerable: true, get: function () { return iso_js_1.ZodMiniISODuration; } });
|
|
59
|
+
// coerce
|
|
60
|
+
exports.coerce = __importStar(require("./coerce.js"));
|
|
@@ -23,8 +23,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.ZodMiniTransform = exports.ZodMiniFile = exports.ZodMiniLiteral = exports.ZodMiniEnum = exports.ZodMiniSet = exports.ZodMiniMap = exports.ZodMiniRecord = exports.ZodMiniTuple = exports.ZodMiniIntersection = exports.ZodMiniDiscriminatedUnion = exports.ZodMiniUnion = exports.ZodMiniObject = exports.ZodMiniArray = exports.ZodMiniDate = exports.ZodMiniVoid = exports.ZodMiniNever = exports.ZodMiniUnknown = exports.ZodMiniAny = exports.ZodMiniNull = exports.ZodMiniUndefined = exports.ZodMiniSymbol = exports.ZodMiniBigIntFormat = exports.ZodMiniBigInt = exports.ZodMiniBoolean = exports.ZodMiniNumberFormat = exports.ZodMiniNumber = exports.ZodMiniJWT = exports.ZodMiniE164 = exports.ZodMiniBase64URL = exports.ZodMiniBase64 = exports.ZodMiniCIDRv6 = exports.ZodMiniCIDRv4 = exports.ZodMiniIPv6 = exports.ZodMiniIPv4 = exports.ZodMiniKSUID = exports.ZodMiniXID = exports.ZodMiniULID = exports.ZodMiniCUID2 = exports.ZodMiniCUID = exports.ZodMiniNanoID = exports.ZodMiniEmoji = exports.ZodMiniURL = exports.ZodMiniUUID = exports.ZodMiniGUID = exports.ZodMiniEmail = exports.ZodMiniStringFormat = exports.ZodMiniString = exports.ZodMiniType =
|
|
27
|
-
exports.stringbool = exports.ZodMiniCustom = exports.ZodMiniPromise = exports.ZodMiniLazy = exports.ZodMiniTemplateLiteral = exports.ZodMiniReadonly = exports.ZodMiniPipe = exports.ZodMiniNaN = exports.ZodMiniCatch = exports.ZodMiniSuccess = exports.ZodMiniNonOptional = exports.ZodMiniPrefault = exports.ZodMiniDefault =
|
|
26
|
+
exports.ZodMiniNullable = exports.ZodMiniOptional = exports.ZodMiniTransform = exports.ZodMiniFile = exports.ZodMiniLiteral = exports.ZodMiniEnum = exports.ZodMiniSet = exports.ZodMiniMap = exports.ZodMiniRecord = exports.ZodMiniTuple = exports.ZodMiniIntersection = exports.ZodMiniDiscriminatedUnion = exports.ZodMiniUnion = exports.ZodMiniObject = exports.ZodMiniArray = exports.ZodMiniDate = exports.ZodMiniVoid = exports.ZodMiniNever = exports.ZodMiniUnknown = exports.ZodMiniAny = exports.ZodMiniNull = exports.ZodMiniUndefined = exports.ZodMiniSymbol = exports.ZodMiniBigIntFormat = exports.ZodMiniBigInt = exports.ZodMiniBoolean = exports.ZodMiniNumberFormat = exports.ZodMiniNumber = exports.ZodMiniJWT = exports.ZodMiniE164 = exports.ZodMiniBase64URL = exports.ZodMiniBase64 = exports.ZodMiniCIDRv6 = exports.ZodMiniCIDRv4 = exports.ZodMiniIPv6 = exports.ZodMiniIPv4 = exports.ZodMiniKSUID = exports.ZodMiniXID = exports.ZodMiniULID = exports.ZodMiniCUID2 = exports.ZodMiniCUID = exports.ZodMiniNanoID = exports.ZodMiniEmoji = exports.ZodMiniURL = exports.ZodMiniUUID = exports.ZodMiniGUID = exports.ZodMiniEmail = exports.ZodMiniStringFormat = exports.ZodMiniString = exports.ZodMiniType = void 0;
|
|
27
|
+
exports.stringbool = exports.ZodMiniCustom = exports.ZodMiniPromise = exports.ZodMiniLazy = exports.ZodMiniTemplateLiteral = exports.ZodMiniReadonly = exports.ZodMiniPipe = exports.ZodMiniNaN = exports.ZodMiniCatch = exports.ZodMiniSuccess = exports.ZodMiniNonOptional = exports.ZodMiniPrefault = exports.ZodMiniDefault = void 0;
|
|
28
28
|
exports.string = string;
|
|
29
29
|
exports.email = email;
|
|
30
30
|
exports.guid = guid;
|
|
@@ -112,8 +112,6 @@ exports.json = json;
|
|
|
112
112
|
const core = __importStar(require("zod/v4/core"));
|
|
113
113
|
const core_1 = require("zod/v4/core");
|
|
114
114
|
const parse = __importStar(require("./parse.js"));
|
|
115
|
-
exports.coerce = __importStar(require("./coerce.js"));
|
|
116
|
-
exports.iso = __importStar(require("./iso.js"));
|
|
117
115
|
exports.ZodMiniType = core.$constructor("ZodMiniType", (inst, def) => {
|
|
118
116
|
if (!inst._zod)
|
|
119
117
|
throw new Error("Uninitialized schema in mixin ZodMiniType.");
|
|
@@ -9,3 +9,9 @@ import { config } from "zod/v4/core";
|
|
|
9
9
|
import en from "zod/v4/locales/en.js";
|
|
10
10
|
config(en());
|
|
11
11
|
export { globalRegistry, registry, config, function, $output, $input, $brand, clone, regexes, treeifyError, prettifyError, formatError, flattenError, toJSONSchema, locales, } from "zod/v4/core";
|
|
12
|
+
// iso
|
|
13
|
+
// must be exported from top-level
|
|
14
|
+
// https://github.com/colinhacks/zod/issues/4491
|
|
15
|
+
export { ZodISODateTime, ZodISODate, ZodISOTime, ZodISODuration } from "./iso.js";
|
|
16
|
+
export * as iso from "./iso.js";
|
|
17
|
+
export * as coerce from "./coerce.js";
|
|
@@ -3,8 +3,6 @@ import { util } from "zod/v4/core";
|
|
|
3
3
|
import * as checks from "./checks.js";
|
|
4
4
|
import * as iso from "./iso.js";
|
|
5
5
|
import * as parse from "./parse.js";
|
|
6
|
-
export * as iso from "./iso.js";
|
|
7
|
-
export * as coerce from "./coerce.js";
|
|
8
6
|
export const ZodType = /*@__PURE__*/ core.$constructor("ZodType", (inst, def) => {
|
|
9
7
|
core.$ZodType.init(inst, def);
|
|
10
8
|
inst.def = def;
|
|
@@ -727,7 +725,7 @@ export const ZodFile = /*@__PURE__*/ core.$constructor("ZodFile", (inst, def) =>
|
|
|
727
725
|
ZodType.init(inst, def);
|
|
728
726
|
inst.min = (size, params) => inst.check(core._minSize(size, params));
|
|
729
727
|
inst.max = (size, params) => inst.check(core._maxSize(size, params));
|
|
730
|
-
inst.mime = (types, params) => inst.check(core._mime(types, params));
|
|
728
|
+
inst.mime = (types, params) => inst.check(core._mime(Array.isArray(types) ? types : [types], params));
|
|
731
729
|
});
|
|
732
730
|
export function file(params) {
|
|
733
731
|
return core._file(ZodFile, params);
|
|
@@ -28,8 +28,6 @@ export class JSONSchemaGenerator {
|
|
|
28
28
|
if (isCycle) {
|
|
29
29
|
seen.cycle = _params.path;
|
|
30
30
|
}
|
|
31
|
-
seen.count++;
|
|
32
|
-
// break cycle
|
|
33
31
|
return seen.schema;
|
|
34
32
|
}
|
|
35
33
|
// initialize
|
|
@@ -243,16 +241,20 @@ export class JSONSchemaGenerator {
|
|
|
243
241
|
}
|
|
244
242
|
case "intersection": {
|
|
245
243
|
const json = _json;
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
244
|
+
const a = this.process(def.left, {
|
|
245
|
+
...params,
|
|
246
|
+
path: [...params.path, "allOf", 0],
|
|
247
|
+
});
|
|
248
|
+
const b = this.process(def.right, {
|
|
249
|
+
...params,
|
|
250
|
+
path: [...params.path, "allOf", 1],
|
|
251
|
+
});
|
|
252
|
+
const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
|
|
253
|
+
const allOf = [
|
|
254
|
+
...(isSimpleIntersection(a) ? a.allOf : [a]),
|
|
255
|
+
...(isSimpleIntersection(b) ? b.allOf : [b]),
|
|
255
256
|
];
|
|
257
|
+
json.allOf = allOf;
|
|
256
258
|
break;
|
|
257
259
|
}
|
|
258
260
|
case "tuple": {
|
|
@@ -356,9 +358,35 @@ export class JSONSchemaGenerator {
|
|
|
356
358
|
break;
|
|
357
359
|
}
|
|
358
360
|
case "file": {
|
|
359
|
-
|
|
360
|
-
|
|
361
|
+
const json = _json;
|
|
362
|
+
const file = {
|
|
363
|
+
type: "string",
|
|
364
|
+
format: "binary",
|
|
365
|
+
contentEncoding: "binary",
|
|
366
|
+
};
|
|
367
|
+
const { minimum, maximum, mime } = schema._zod.bag;
|
|
368
|
+
if (minimum !== undefined)
|
|
369
|
+
file.minLength = minimum;
|
|
370
|
+
if (maximum !== undefined)
|
|
371
|
+
file.maxLength = maximum;
|
|
372
|
+
if (mime) {
|
|
373
|
+
if (mime.length === 1) {
|
|
374
|
+
file.contentMediaType = mime[0];
|
|
375
|
+
Object.assign(json, file);
|
|
376
|
+
}
|
|
377
|
+
else {
|
|
378
|
+
json.anyOf = mime.map((m) => {
|
|
379
|
+
const mFile = { ...file, contentMediaType: m };
|
|
380
|
+
return mFile;
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
else {
|
|
385
|
+
Object.assign(json, file);
|
|
361
386
|
}
|
|
387
|
+
// if (this.unrepresentable === "throw") {
|
|
388
|
+
// throw new Error("File cannot be represented in JSON Schema");
|
|
389
|
+
// }
|
|
362
390
|
break;
|
|
363
391
|
}
|
|
364
392
|
case "transform": {
|
|
@@ -5,3 +5,8 @@ export * from "./checks.js";
|
|
|
5
5
|
export { globalRegistry, registry, config, $output, $input, $brand, function, clone, regexes, treeifyError, prettifyError, formatError, flattenError, toJSONSchema, locales, } from "zod/v4/core";
|
|
6
6
|
/** A special constant with type `never` */
|
|
7
7
|
// export const NEVER = {} as never;
|
|
8
|
+
// iso
|
|
9
|
+
export * as iso from "./iso.js";
|
|
10
|
+
export { ZodMiniISODateTime, ZodMiniISODate, ZodMiniISOTime, ZodMiniISODuration, } from "./iso.js";
|
|
11
|
+
// coerce
|
|
12
|
+
export * as coerce from "./coerce.js";
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import * as core from "zod/v4/core";
|
|
2
2
|
import { util } from "zod/v4/core";
|
|
3
3
|
import * as parse from "./parse.js";
|
|
4
|
-
export * as coerce from "./coerce.js";
|
|
5
|
-
export * as iso from "./iso.js";
|
|
6
4
|
export const ZodMiniType = /*@__PURE__*/ core.$constructor("ZodMiniType", (inst, def) => {
|
|
7
5
|
if (!inst._zod)
|
|
8
6
|
throw new Error("Uninitialized schema in mixin ZodMiniType.");
|
|
@@ -6,3 +6,7 @@ export * from "./parse.js";
|
|
|
6
6
|
export * from "./compat.js";
|
|
7
7
|
export type { infer, output, input } from "zod/v4/core";
|
|
8
8
|
export { globalRegistry, type GlobalMeta, registry, config, function, $output, $input, $brand, clone, regexes, treeifyError, prettifyError, formatError, flattenError, toJSONSchema, locales, } from "zod/v4/core";
|
|
9
|
+
export { ZodISODateTime, ZodISODate, ZodISOTime, ZodISODuration } from "./iso.js";
|
|
10
|
+
export * as iso from "./iso.js";
|
|
11
|
+
export type { ZodCoercedString, ZodCoercedNumber, ZodCoercedBigInt, ZodCoercedBoolean, ZodCoercedDate, } from "./coerce.js";
|
|
12
|
+
export * as coerce from "./coerce.js";
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import * as core from "zod/v4/core";
|
|
2
2
|
import { util } from "zod/v4/core";
|
|
3
3
|
import * as parse from "./parse.js";
|
|
4
|
-
export * as iso from "./iso.js";
|
|
5
|
-
export * as coerce from "./coerce.js";
|
|
6
4
|
export interface RefinementCtx<T = unknown> extends core.ParsePayload<T> {
|
|
7
5
|
addIssue(arg: string | core.$ZodRawIssue | Partial<core.$ZodIssueCustom>): void;
|
|
8
6
|
}
|
|
@@ -535,7 +533,7 @@ export interface ZodFile extends ZodType {
|
|
|
535
533
|
_zod: core.$ZodFileInternals;
|
|
536
534
|
min(size: number, params?: string | core.$ZodCheckMinSizeParams): this;
|
|
537
535
|
max(size: number, params?: string | core.$ZodCheckMaxSizeParams): this;
|
|
538
|
-
mime(types: Array<util.MimeTypes>, params?: string | core.$ZodCheckMimeTypeParams): this;
|
|
536
|
+
mime(types: util.MimeTypes | Array<util.MimeTypes>, params?: string | core.$ZodCheckMimeTypeParams): this;
|
|
539
537
|
}
|
|
540
538
|
export declare const ZodFile: core.$constructor<ZodFile>;
|
|
541
539
|
export declare function file(params?: string | core.$ZodFileParams): ZodFile;
|
|
@@ -734,6 +734,11 @@ export interface $ZodFileDef extends $ZodTypeDef {
|
|
|
734
734
|
export interface $ZodFileInternals extends $ZodTypeInternals<File, File> {
|
|
735
735
|
def: $ZodFileDef;
|
|
736
736
|
isst: errors.$ZodIssueInvalidType;
|
|
737
|
+
bag: util.LoosePartial<{
|
|
738
|
+
minimum: number;
|
|
739
|
+
maximum: number;
|
|
740
|
+
mime: util.MimeTypes[];
|
|
741
|
+
}>;
|
|
737
742
|
}
|
|
738
743
|
export interface $ZodFile extends $ZodType {
|
|
739
744
|
_zod: $ZodFileInternals;
|
|
@@ -5,3 +5,6 @@ export * from "./checks.js";
|
|
|
5
5
|
export type { infer, output, input } from "zod/v4/core";
|
|
6
6
|
export { globalRegistry, registry, config, $output, $input, $brand, function, clone, regexes, treeifyError, prettifyError, formatError, flattenError, toJSONSchema, locales, } from "zod/v4/core";
|
|
7
7
|
/** A special constant with type `never` */
|
|
8
|
+
export * as iso from "./iso.js";
|
|
9
|
+
export { ZodMiniISODateTime, ZodMiniISODate, ZodMiniISOTime, ZodMiniISODuration, } from "./iso.js";
|
|
10
|
+
export * as coerce from "./coerce.js";
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import * as core from "zod/v4/core";
|
|
2
2
|
import { util } from "zod/v4/core";
|
|
3
|
-
export * as coerce from "./coerce.js";
|
|
4
|
-
export * as iso from "./iso.js";
|
|
5
3
|
type SomeType = core.$ZodType;
|
|
6
4
|
export interface ZodMiniType<out Output = unknown, out Input = unknown> extends core.$ZodType<Output, Input> {
|
|
7
5
|
check(...checks: (core.CheckFn<this["_zod"]["output"]> | core.$ZodCheck<this["_zod"]["output"]>)[]): this;
|
package/package.json
CHANGED