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.
- package/index.cjs +17 -7
- package/package.json +1 -1
- package/src/v4/classic/external.ts +0 -1
- package/src/v4/classic/parse.ts +49 -0
- package/src/v4/classic/schemas.ts +145 -7
- package/src/v4/classic/tests/catch.test.ts +25 -0
- package/src/v4/classic/tests/codec-examples.test.ts +538 -0
- package/src/v4/classic/tests/codec.test.ts +532 -0
- package/src/v4/classic/tests/continuability.test.ts +1 -1
- package/src/v4/classic/tests/default.test.ts +32 -0
- package/src/v4/classic/tests/firstparty.test.ts +4 -0
- package/src/v4/classic/tests/function.test.ts +31 -31
- package/src/v4/classic/tests/hash.test.ts +68 -0
- package/src/v4/classic/tests/nonoptional.test.ts +15 -0
- package/src/v4/classic/tests/object.test.ts +31 -0
- package/src/v4/classic/tests/pipe.test.ts +25 -5
- package/src/v4/classic/tests/prefault.test.ts +25 -0
- package/src/v4/classic/tests/preprocess.test.ts +1 -6
- package/src/v4/classic/tests/refine.test.ts +76 -3
- package/src/v4/classic/tests/string-formats.test.ts +16 -0
- package/src/v4/classic/tests/string.test.ts +82 -1
- package/src/v4/classic/tests/stringbool.test.ts +40 -0
- package/src/v4/classic/tests/template-literal.test.ts +1 -1
- package/src/v4/classic/tests/to-json-schema.test.ts +21 -2
- package/src/v4/classic/tests/transform.test.ts +7 -0
- package/src/v4/classic/tests/union.test.ts +1 -1
- package/src/v4/core/api.ts +25 -35
- package/src/v4/core/core.ts +7 -26
- package/src/v4/core/index.ts +0 -1
- package/src/v4/core/json-schema.ts +1 -0
- package/src/v4/core/parse.ts +101 -0
- package/src/v4/core/regexes.ts +40 -1
- package/src/v4/core/schemas.ts +521 -129
- package/src/v4/core/to-json-schema.ts +43 -8
- package/src/v4/core/util.ts +73 -0
- package/src/v4/mini/external.ts +0 -1
- package/src/v4/mini/parse.ts +14 -1
- package/src/v4/mini/schemas.ts +153 -12
- package/src/v4/mini/tests/codec.test.ts +499 -0
- package/src/v4/mini/tests/object.test.ts +9 -0
- package/src/v4/mini/tests/string.test.ts +16 -0
- package/v3/index.cjs +17 -7
- package/v4/classic/coerce.cjs +17 -7
- package/v4/classic/compat.cjs +17 -7
- package/v4/classic/errors.cjs +17 -7
- package/v4/classic/external.cjs +18 -9
- package/v4/classic/external.d.cts +1 -1
- package/v4/classic/external.d.ts +1 -1
- package/v4/classic/external.js +1 -1
- package/v4/classic/index.cjs +17 -7
- package/v4/classic/iso.cjs +17 -7
- package/v4/classic/parse.cjs +27 -8
- package/v4/classic/parse.d.cts +8 -0
- package/v4/classic/parse.d.ts +8 -0
- package/v4/classic/parse.js +9 -0
- package/v4/classic/schemas.cjs +76 -11
- package/v4/classic/schemas.d.cts +48 -2
- package/v4/classic/schemas.d.ts +48 -2
- package/v4/classic/schemas.js +51 -3
- package/v4/core/api.cjs +36 -35
- package/v4/core/api.d.cts +3 -4
- package/v4/core/api.d.ts +3 -4
- package/v4/core/api.js +19 -24
- package/v4/core/checks.cjs +17 -7
- package/v4/core/core.cjs +8 -1
- package/v4/core/core.d.cts +3 -0
- package/v4/core/core.d.ts +3 -0
- package/v4/core/core.js +6 -0
- package/v4/core/errors.cjs +17 -7
- package/v4/core/index.cjs +17 -8
- package/v4/core/index.d.cts +0 -1
- package/v4/core/index.d.ts +0 -1
- package/v4/core/index.js +0 -1
- package/v4/core/json-schema.d.cts +1 -0
- package/v4/core/json-schema.d.ts +1 -0
- package/v4/core/parse.cjs +62 -8
- package/v4/core/parse.d.cts +24 -0
- package/v4/core/parse.d.ts +24 -0
- package/v4/core/parse.js +36 -0
- package/v4/core/regexes.cjs +34 -2
- package/v4/core/regexes.d.cts +16 -0
- package/v4/core/regexes.d.ts +16 -0
- package/v4/core/regexes.js +32 -1
- package/v4/core/schemas.cjs +326 -84
- package/v4/core/schemas.d.cts +61 -3
- package/v4/core/schemas.d.ts +61 -3
- package/v4/core/schemas.js +308 -76
- package/v4/core/to-json-schema.cjs +42 -5
- package/v4/core/to-json-schema.d.cts +4 -3
- package/v4/core/to-json-schema.d.ts +4 -3
- package/v4/core/to-json-schema.js +42 -5
- package/v4/core/util.cjs +69 -0
- package/v4/core/util.d.cts +10 -0
- package/v4/core/util.d.ts +10 -0
- package/v4/core/util.js +62 -0
- package/v4/locales/ar.cjs +17 -7
- package/v4/locales/az.cjs +17 -7
- package/v4/locales/be.cjs +17 -7
- package/v4/locales/bg.cjs +17 -7
- package/v4/locales/ca.cjs +17 -7
- package/v4/locales/cs.cjs +17 -7
- package/v4/locales/da.cjs +17 -7
- package/v4/locales/de.cjs +17 -7
- package/v4/locales/en.cjs +17 -7
- package/v4/locales/eo.cjs +17 -7
- package/v4/locales/es.cjs +17 -7
- package/v4/locales/fa.cjs +17 -7
- package/v4/locales/fi.cjs +17 -7
- package/v4/locales/fr-CA.cjs +17 -7
- package/v4/locales/fr.cjs +17 -7
- package/v4/locales/he.cjs +17 -7
- package/v4/locales/hu.cjs +17 -7
- package/v4/locales/id.cjs +17 -7
- package/v4/locales/is.cjs +17 -7
- package/v4/locales/it.cjs +17 -7
- package/v4/locales/ja.cjs +17 -7
- package/v4/locales/kh.cjs +17 -7
- package/v4/locales/ko.cjs +17 -7
- package/v4/locales/mk.cjs +17 -7
- package/v4/locales/ms.cjs +17 -7
- package/v4/locales/nl.cjs +17 -7
- package/v4/locales/no.cjs +17 -7
- package/v4/locales/ota.cjs +17 -7
- package/v4/locales/pl.cjs +17 -7
- package/v4/locales/ps.cjs +17 -7
- package/v4/locales/pt.cjs +17 -7
- package/v4/locales/ru.cjs +17 -7
- package/v4/locales/sl.cjs +17 -7
- package/v4/locales/sv.cjs +17 -7
- package/v4/locales/ta.cjs +17 -7
- package/v4/locales/th.cjs +17 -7
- package/v4/locales/tr.cjs +17 -7
- package/v4/locales/ua.cjs +17 -7
- package/v4/locales/ur.cjs +17 -7
- package/v4/locales/vi.cjs +17 -7
- package/v4/locales/yo.cjs +17 -7
- package/v4/locales/zh-CN.cjs +17 -7
- package/v4/locales/zh-TW.cjs +17 -7
- package/v4/mini/coerce.cjs +17 -7
- package/v4/mini/external.cjs +18 -9
- package/v4/mini/external.d.cts +1 -1
- package/v4/mini/external.d.ts +1 -1
- package/v4/mini/external.js +1 -1
- package/v4/mini/index.cjs +17 -7
- package/v4/mini/iso.cjs +17 -7
- package/v4/mini/parse.cjs +9 -1
- package/v4/mini/parse.d.cts +1 -1
- package/v4/mini/parse.d.ts +1 -1
- package/v4/mini/parse.js +1 -1
- package/v4/mini/schemas.cjs +75 -10
- package/v4/mini/schemas.d.cts +49 -1
- package/v4/mini/schemas.d.ts +49 -1
- package/v4/mini/schemas.js +49 -2
- package/src/v4/core/function.ts +0 -176
- package/v4/core/function.cjs +0 -102
- package/v4/core/function.d.cts +0 -52
- package/v4/core/function.d.ts +0 -52
- package/v4/core/function.js +0 -75
package/v4/core/schemas.cjs
CHANGED
|
@@ -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 (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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.$
|
|
27
|
-
exports.$ZodCustom = exports.$ZodLazy = exports.$ZodPromise = exports.$ZodTemplateLiteral = exports.$ZodReadonly = exports.$ZodPipe = exports.$ZodNaN = exports.$ZodCatch = exports.$ZodSuccess = exports.$ZodNonOptional = exports.$ZodPrefault = exports.$ZodDefault = exports.$ZodNullable = exports.$ZodOptional = exports.$ZodTransform = exports.$ZodFile = exports.$ZodLiteral = exports.$ZodEnum = void 0;
|
|
36
|
+
exports.$ZodMap = exports.$ZodRecord = exports.$ZodTuple = exports.$ZodIntersection = exports.$ZodDiscriminatedUnion = exports.$ZodUnion = exports.$ZodObjectJIT = 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.$ZodISODuration = exports.$ZodISOTime = exports.$ZodISODate = exports.$ZodISODateTime = exports.$ZodKSUID = exports.$ZodXID = exports.$ZodULID = exports.$ZodCUID2 = exports.$ZodCUID = exports.$ZodNanoID = exports.$ZodEmoji = exports.$ZodURL = exports.$ZodEmail = exports.$ZodUUID = exports.$ZodGUID = exports.$ZodStringFormat = exports.$ZodString = exports.clone = exports.$ZodType = void 0;
|
|
37
|
+
exports.$ZodCustom = exports.$ZodLazy = exports.$ZodPromise = exports.$ZodFunction = exports.$ZodTemplateLiteral = exports.$ZodReadonly = exports.$ZodCodec = exports.$ZodPipe = exports.$ZodNaN = exports.$ZodCatch = exports.$ZodSuccess = exports.$ZodNonOptional = exports.$ZodPrefault = exports.$ZodDefault = exports.$ZodNullable = exports.$ZodOptional = exports.$ZodTransform = exports.$ZodFile = exports.$ZodLiteral = exports.$ZodEnum = exports.$ZodSet = void 0;
|
|
28
38
|
exports.isValidBase64 = isValidBase64;
|
|
29
39
|
exports.isValidBase64URL = isValidBase64URL;
|
|
30
40
|
exports.isValidJWT = isValidJWT;
|
|
@@ -46,7 +56,6 @@ exports.$ZodType = core.$constructor("$ZodType", (inst, def) => {
|
|
|
46
56
|
if (inst._zod.traits.has("$ZodCheck")) {
|
|
47
57
|
checks.unshift(inst);
|
|
48
58
|
}
|
|
49
|
-
//
|
|
50
59
|
for (const ch of checks) {
|
|
51
60
|
for (const fn of ch._zod.onattach) {
|
|
52
61
|
fn(inst);
|
|
@@ -103,7 +112,47 @@ exports.$ZodType = core.$constructor("$ZodType", (inst, def) => {
|
|
|
103
112
|
}
|
|
104
113
|
return payload;
|
|
105
114
|
};
|
|
115
|
+
// const handleChecksResult = (
|
|
116
|
+
// checkResult: ParsePayload,
|
|
117
|
+
// originalResult: ParsePayload,
|
|
118
|
+
// ctx: ParseContextInternal
|
|
119
|
+
// ): util.MaybeAsync<ParsePayload> => {
|
|
120
|
+
// // if the checks mutated the value && there are no issues, re-parse the result
|
|
121
|
+
// if (checkResult.value !== originalResult.value && !checkResult.issues.length)
|
|
122
|
+
// return inst._zod.parse(checkResult, ctx);
|
|
123
|
+
// return originalResult;
|
|
124
|
+
// };
|
|
125
|
+
const handleCanaryResult = (canary, payload, ctx) => {
|
|
126
|
+
// abort if the canary is aborted
|
|
127
|
+
if (util.aborted(canary)) {
|
|
128
|
+
canary.aborted = true;
|
|
129
|
+
return canary;
|
|
130
|
+
}
|
|
131
|
+
// run checks first, then
|
|
132
|
+
const checkResult = runChecks(payload, checks, ctx);
|
|
133
|
+
if (checkResult instanceof Promise) {
|
|
134
|
+
if (ctx.async === false)
|
|
135
|
+
throw new core.$ZodAsyncError();
|
|
136
|
+
return checkResult.then((checkResult) => inst._zod.parse(checkResult, ctx));
|
|
137
|
+
}
|
|
138
|
+
return inst._zod.parse(checkResult, ctx);
|
|
139
|
+
};
|
|
106
140
|
inst._zod.run = (payload, ctx) => {
|
|
141
|
+
if (ctx.skipChecks) {
|
|
142
|
+
return inst._zod.parse(payload, ctx);
|
|
143
|
+
}
|
|
144
|
+
if (ctx.direction === "backward") {
|
|
145
|
+
// run canary
|
|
146
|
+
// initial pass (no checks)
|
|
147
|
+
const canary = inst._zod.parse({ value: payload.value, issues: [] }, { ...ctx, skipChecks: true });
|
|
148
|
+
if (canary instanceof Promise) {
|
|
149
|
+
return canary.then((canary) => {
|
|
150
|
+
return handleCanaryResult(canary, payload, ctx);
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
return handleCanaryResult(canary, payload, ctx);
|
|
154
|
+
}
|
|
155
|
+
// forward
|
|
107
156
|
const result = inst._zod.parse(payload, ctx);
|
|
108
157
|
if (result instanceof Promise) {
|
|
109
158
|
if (ctx.async === false)
|
|
@@ -704,25 +753,61 @@ function handlePropertyResult(result, final, key, input) {
|
|
|
704
753
|
final.value[key] = result.value;
|
|
705
754
|
}
|
|
706
755
|
}
|
|
756
|
+
function normalizeDef(def) {
|
|
757
|
+
const keys = Object.keys(def.shape);
|
|
758
|
+
for (const k of keys) {
|
|
759
|
+
if (!def.shape[k]._zod.traits.has("$ZodType")) {
|
|
760
|
+
throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
const okeys = util.optionalKeys(def.shape);
|
|
764
|
+
return {
|
|
765
|
+
...def,
|
|
766
|
+
keys,
|
|
767
|
+
keySet: new Set(keys),
|
|
768
|
+
numKeys: keys.length,
|
|
769
|
+
optionalKeys: new Set(okeys),
|
|
770
|
+
};
|
|
771
|
+
}
|
|
772
|
+
function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
773
|
+
const unrecognized = [];
|
|
774
|
+
// iterate over input keys
|
|
775
|
+
const keySet = def.keySet;
|
|
776
|
+
const _catchall = def.catchall._zod;
|
|
777
|
+
const t = _catchall.def.type;
|
|
778
|
+
for (const key of Object.keys(input)) {
|
|
779
|
+
if (keySet.has(key))
|
|
780
|
+
continue;
|
|
781
|
+
if (t === "never") {
|
|
782
|
+
unrecognized.push(key);
|
|
783
|
+
continue;
|
|
784
|
+
}
|
|
785
|
+
const r = _catchall.run({ value: input[key], issues: [] }, ctx);
|
|
786
|
+
if (r instanceof Promise) {
|
|
787
|
+
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input)));
|
|
788
|
+
}
|
|
789
|
+
else {
|
|
790
|
+
handlePropertyResult(r, payload, key, input);
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
if (unrecognized.length) {
|
|
794
|
+
payload.issues.push({
|
|
795
|
+
code: "unrecognized_keys",
|
|
796
|
+
keys: unrecognized,
|
|
797
|
+
input,
|
|
798
|
+
inst,
|
|
799
|
+
});
|
|
800
|
+
}
|
|
801
|
+
if (!proms.length)
|
|
802
|
+
return payload;
|
|
803
|
+
return Promise.all(proms).then(() => {
|
|
804
|
+
return payload;
|
|
805
|
+
});
|
|
806
|
+
}
|
|
707
807
|
exports.$ZodObject = core.$constructor("$ZodObject", (inst, def) => {
|
|
708
808
|
// requires cast because technically $ZodObject doesn't extend
|
|
709
809
|
exports.$ZodType.init(inst, def);
|
|
710
|
-
const _normalized = util.cached(() =>
|
|
711
|
-
const keys = Object.keys(def.shape);
|
|
712
|
-
for (const k of keys) {
|
|
713
|
-
if (!def.shape[k]._zod.traits.has("$ZodType")) {
|
|
714
|
-
throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
|
-
const okeys = util.optionalKeys(def.shape);
|
|
718
|
-
return {
|
|
719
|
-
shape: def.shape,
|
|
720
|
-
keys,
|
|
721
|
-
keySet: new Set(keys),
|
|
722
|
-
numKeys: keys.length,
|
|
723
|
-
optionalKeys: new Set(okeys),
|
|
724
|
-
};
|
|
725
|
-
});
|
|
810
|
+
const _normalized = util.cached(() => normalizeDef(def));
|
|
726
811
|
util.defineLazy(inst._zod, "propValues", () => {
|
|
727
812
|
const shape = def.shape;
|
|
728
813
|
const propValues = {};
|
|
@@ -736,6 +821,45 @@ exports.$ZodObject = core.$constructor("$ZodObject", (inst, def) => {
|
|
|
736
821
|
}
|
|
737
822
|
return propValues;
|
|
738
823
|
});
|
|
824
|
+
const isObject = util.isObject;
|
|
825
|
+
const catchall = def.catchall;
|
|
826
|
+
let value;
|
|
827
|
+
inst._zod.parse = (payload, ctx) => {
|
|
828
|
+
value ?? (value = _normalized.value);
|
|
829
|
+
const input = payload.value;
|
|
830
|
+
if (!isObject(input)) {
|
|
831
|
+
payload.issues.push({
|
|
832
|
+
expected: "object",
|
|
833
|
+
code: "invalid_type",
|
|
834
|
+
input,
|
|
835
|
+
inst,
|
|
836
|
+
});
|
|
837
|
+
return payload;
|
|
838
|
+
}
|
|
839
|
+
payload.value = {};
|
|
840
|
+
const proms = [];
|
|
841
|
+
const shape = value.shape;
|
|
842
|
+
for (const key of value.keys) {
|
|
843
|
+
const el = shape[key];
|
|
844
|
+
const r = el._zod.run({ value: input[key], issues: [] }, ctx);
|
|
845
|
+
if (r instanceof Promise) {
|
|
846
|
+
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input)));
|
|
847
|
+
}
|
|
848
|
+
else {
|
|
849
|
+
handlePropertyResult(r, payload, key, input);
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
if (!catchall) {
|
|
853
|
+
return proms.length ? Promise.all(proms).then(() => payload) : payload;
|
|
854
|
+
}
|
|
855
|
+
return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
|
|
856
|
+
};
|
|
857
|
+
});
|
|
858
|
+
exports.$ZodObjectJIT = core.$constructor("$ZodObjectJIT", (inst, def) => {
|
|
859
|
+
// requires cast because technically $ZodObject doesn't extend
|
|
860
|
+
exports.$ZodObject.init(inst, def);
|
|
861
|
+
const superParse = inst._zod.parse;
|
|
862
|
+
const _normalized = util.cached(() => normalizeDef(def));
|
|
739
863
|
const generateFastpass = (shape) => {
|
|
740
864
|
const doc = new doc_js_1.Doc(["shape", "payload", "ctx"]);
|
|
741
865
|
const normalized = _normalized.value;
|
|
@@ -796,63 +920,16 @@ exports.$ZodObject = core.$constructor("$ZodObject", (inst, def) => {
|
|
|
796
920
|
});
|
|
797
921
|
return payload;
|
|
798
922
|
}
|
|
799
|
-
const proms = [];
|
|
800
923
|
if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
|
|
801
924
|
// always synchronous
|
|
802
925
|
if (!fastpass)
|
|
803
926
|
fastpass = generateFastpass(def.shape);
|
|
804
927
|
payload = fastpass(payload, ctx);
|
|
928
|
+
if (!catchall)
|
|
929
|
+
return payload;
|
|
930
|
+
return handleCatchall([], input, payload, ctx, value, inst);
|
|
805
931
|
}
|
|
806
|
-
|
|
807
|
-
payload.value = {};
|
|
808
|
-
const shape = value.shape;
|
|
809
|
-
for (const key of value.keys) {
|
|
810
|
-
const el = shape[key];
|
|
811
|
-
const r = el._zod.run({ value: input[key], issues: [] }, ctx);
|
|
812
|
-
if (r instanceof Promise) {
|
|
813
|
-
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input)));
|
|
814
|
-
}
|
|
815
|
-
else {
|
|
816
|
-
handlePropertyResult(r, payload, key, input);
|
|
817
|
-
}
|
|
818
|
-
}
|
|
819
|
-
}
|
|
820
|
-
if (!catchall) {
|
|
821
|
-
return proms.length ? Promise.all(proms).then(() => payload) : payload;
|
|
822
|
-
}
|
|
823
|
-
const unrecognized = [];
|
|
824
|
-
// iterate over input keys
|
|
825
|
-
const keySet = value.keySet;
|
|
826
|
-
const _catchall = catchall._zod;
|
|
827
|
-
const t = _catchall.def.type;
|
|
828
|
-
for (const key of Object.keys(input)) {
|
|
829
|
-
if (keySet.has(key))
|
|
830
|
-
continue;
|
|
831
|
-
if (t === "never") {
|
|
832
|
-
unrecognized.push(key);
|
|
833
|
-
continue;
|
|
834
|
-
}
|
|
835
|
-
const r = _catchall.run({ value: input[key], issues: [] }, ctx);
|
|
836
|
-
if (r instanceof Promise) {
|
|
837
|
-
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input)));
|
|
838
|
-
}
|
|
839
|
-
else {
|
|
840
|
-
handlePropertyResult(r, payload, key, input);
|
|
841
|
-
}
|
|
842
|
-
}
|
|
843
|
-
if (unrecognized.length) {
|
|
844
|
-
payload.issues.push({
|
|
845
|
-
code: "unrecognized_keys",
|
|
846
|
-
keys: unrecognized,
|
|
847
|
-
input,
|
|
848
|
-
inst,
|
|
849
|
-
});
|
|
850
|
-
}
|
|
851
|
-
if (!proms.length)
|
|
852
|
-
return payload;
|
|
853
|
-
return Promise.all(proms).then(() => {
|
|
854
|
-
return payload;
|
|
855
|
-
});
|
|
932
|
+
return superParse(payload, ctx);
|
|
856
933
|
};
|
|
857
934
|
});
|
|
858
935
|
function handleUnionResults(results, final, inst, ctx) {
|
|
@@ -1399,9 +1476,12 @@ exports.$ZodFile = core.$constructor("$ZodFile", (inst, def) => {
|
|
|
1399
1476
|
});
|
|
1400
1477
|
exports.$ZodTransform = core.$constructor("$ZodTransform", (inst, def) => {
|
|
1401
1478
|
exports.$ZodType.init(inst, def);
|
|
1402
|
-
inst._zod.parse = (payload,
|
|
1479
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1480
|
+
if (ctx.direction === "backward") {
|
|
1481
|
+
throw new core.$ZodEncodeError(inst.constructor.name);
|
|
1482
|
+
}
|
|
1403
1483
|
const _out = def.transform(payload.value, payload);
|
|
1404
|
-
if (
|
|
1484
|
+
if (ctx.async) {
|
|
1405
1485
|
const output = _out instanceof Promise ? _out : Promise.resolve(_out);
|
|
1406
1486
|
return output.then((output) => {
|
|
1407
1487
|
payload.value = output;
|
|
@@ -1457,6 +1537,7 @@ exports.$ZodNullable = core.$constructor("$ZodNullable", (inst, def) => {
|
|
|
1457
1537
|
return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : undefined;
|
|
1458
1538
|
});
|
|
1459
1539
|
inst._zod.parse = (payload, ctx) => {
|
|
1540
|
+
// Forward direction (decode): allow null to pass through
|
|
1460
1541
|
if (payload.value === null)
|
|
1461
1542
|
return payload;
|
|
1462
1543
|
return def.innerType._zod.run(payload, ctx);
|
|
@@ -1468,13 +1549,18 @@ exports.$ZodDefault = core.$constructor("$ZodDefault", (inst, def) => {
|
|
|
1468
1549
|
inst._zod.optin = "optional";
|
|
1469
1550
|
util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
1470
1551
|
inst._zod.parse = (payload, ctx) => {
|
|
1552
|
+
if (ctx.direction === "backward") {
|
|
1553
|
+
return def.innerType._zod.run(payload, ctx);
|
|
1554
|
+
}
|
|
1555
|
+
// Forward direction (decode): apply defaults for undefined input
|
|
1471
1556
|
if (payload.value === undefined) {
|
|
1472
1557
|
payload.value = def.defaultValue;
|
|
1473
1558
|
/**
|
|
1474
|
-
* $ZodDefault
|
|
1559
|
+
* $ZodDefault returns the default value immediately in forward direction.
|
|
1475
1560
|
* It doesn't pass the default value into the validator ("prefault"). There's no reason to pass the default value through validation. The validity of the default is enforced by TypeScript statically. Otherwise, it's the responsibility of the user to ensure the default is valid. In the case of pipes with divergent in/out types, you can specify the default on the `in` schema of your ZodPipe to set a "prefault" for the pipe. */
|
|
1476
1561
|
return payload;
|
|
1477
1562
|
}
|
|
1563
|
+
// Forward direction: continue with default handling
|
|
1478
1564
|
const result = def.innerType._zod.run(payload, ctx);
|
|
1479
1565
|
if (result instanceof Promise) {
|
|
1480
1566
|
return result.then((result) => handleDefaultResult(result, def));
|
|
@@ -1493,6 +1579,10 @@ exports.$ZodPrefault = core.$constructor("$ZodPrefault", (inst, def) => {
|
|
|
1493
1579
|
inst._zod.optin = "optional";
|
|
1494
1580
|
util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
1495
1581
|
inst._zod.parse = (payload, ctx) => {
|
|
1582
|
+
if (ctx.direction === "backward") {
|
|
1583
|
+
return def.innerType._zod.run(payload, ctx);
|
|
1584
|
+
}
|
|
1585
|
+
// Forward direction (decode): apply prefault for undefined input
|
|
1496
1586
|
if (payload.value === undefined) {
|
|
1497
1587
|
payload.value = def.defaultValue;
|
|
1498
1588
|
}
|
|
@@ -1527,6 +1617,9 @@ function handleNonOptionalResult(payload, inst) {
|
|
|
1527
1617
|
exports.$ZodSuccess = core.$constructor("$ZodSuccess", (inst, def) => {
|
|
1528
1618
|
exports.$ZodType.init(inst, def);
|
|
1529
1619
|
inst._zod.parse = (payload, ctx) => {
|
|
1620
|
+
if (ctx.direction === "backward") {
|
|
1621
|
+
throw new core.$ZodEncodeError("ZodSuccess");
|
|
1622
|
+
}
|
|
1530
1623
|
const result = def.innerType._zod.run(payload, ctx);
|
|
1531
1624
|
if (result instanceof Promise) {
|
|
1532
1625
|
return result.then((result) => {
|
|
@@ -1544,6 +1637,10 @@ exports.$ZodCatch = core.$constructor("$ZodCatch", (inst, def) => {
|
|
|
1544
1637
|
util.defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
|
1545
1638
|
util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
1546
1639
|
inst._zod.parse = (payload, ctx) => {
|
|
1640
|
+
if (ctx.direction === "backward") {
|
|
1641
|
+
return def.innerType._zod.run(payload, ctx);
|
|
1642
|
+
}
|
|
1643
|
+
// Forward direction (decode): apply catch logic
|
|
1547
1644
|
const result = def.innerType._zod.run(payload, ctx);
|
|
1548
1645
|
if (result instanceof Promise) {
|
|
1549
1646
|
return result.then((result) => {
|
|
@@ -1597,18 +1694,81 @@ exports.$ZodPipe = core.$constructor("$ZodPipe", (inst, def) => {
|
|
|
1597
1694
|
util.defineLazy(inst._zod, "optout", () => def.out._zod.optout);
|
|
1598
1695
|
util.defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
|
|
1599
1696
|
inst._zod.parse = (payload, ctx) => {
|
|
1697
|
+
if (ctx.direction === "backward") {
|
|
1698
|
+
const right = def.out._zod.run(payload, ctx);
|
|
1699
|
+
if (right instanceof Promise) {
|
|
1700
|
+
return right.then((right) => handlePipeResult(right, def.in, ctx));
|
|
1701
|
+
}
|
|
1702
|
+
return handlePipeResult(right, def.in, ctx);
|
|
1703
|
+
}
|
|
1600
1704
|
const left = def.in._zod.run(payload, ctx);
|
|
1601
1705
|
if (left instanceof Promise) {
|
|
1602
|
-
return left.then((left) => handlePipeResult(left, def, ctx));
|
|
1706
|
+
return left.then((left) => handlePipeResult(left, def.out, ctx));
|
|
1707
|
+
}
|
|
1708
|
+
return handlePipeResult(left, def.out, ctx);
|
|
1709
|
+
};
|
|
1710
|
+
});
|
|
1711
|
+
function handlePipeResult(left, next, ctx) {
|
|
1712
|
+
if (left.issues.length) {
|
|
1713
|
+
// prevent further checks
|
|
1714
|
+
left.aborted = true;
|
|
1715
|
+
return left;
|
|
1716
|
+
}
|
|
1717
|
+
return next._zod.run({ value: left.value, issues: left.issues }, ctx);
|
|
1718
|
+
}
|
|
1719
|
+
exports.$ZodCodec = core.$constructor("$ZodCodec", (inst, def) => {
|
|
1720
|
+
exports.$ZodType.init(inst, def);
|
|
1721
|
+
util.defineLazy(inst._zod, "values", () => def.in._zod.values);
|
|
1722
|
+
util.defineLazy(inst._zod, "optin", () => def.in._zod.optin);
|
|
1723
|
+
util.defineLazy(inst._zod, "optout", () => def.out._zod.optout);
|
|
1724
|
+
util.defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
|
|
1725
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1726
|
+
const direction = ctx.direction || "forward";
|
|
1727
|
+
if (direction === "forward") {
|
|
1728
|
+
const left = def.in._zod.run(payload, ctx);
|
|
1729
|
+
if (left instanceof Promise) {
|
|
1730
|
+
return left.then((left) => handleCodecAResult(left, def, ctx));
|
|
1731
|
+
}
|
|
1732
|
+
return handleCodecAResult(left, def, ctx);
|
|
1733
|
+
}
|
|
1734
|
+
else {
|
|
1735
|
+
const right = def.out._zod.run(payload, ctx);
|
|
1736
|
+
if (right instanceof Promise) {
|
|
1737
|
+
return right.then((right) => handleCodecAResult(right, def, ctx));
|
|
1738
|
+
}
|
|
1739
|
+
return handleCodecAResult(right, def, ctx);
|
|
1603
1740
|
}
|
|
1604
|
-
return handlePipeResult(left, def, ctx);
|
|
1605
1741
|
};
|
|
1606
1742
|
});
|
|
1607
|
-
function
|
|
1743
|
+
function handleCodecAResult(result, def, ctx) {
|
|
1744
|
+
if (result.issues.length) {
|
|
1745
|
+
// prevent further checks
|
|
1746
|
+
result.aborted = true;
|
|
1747
|
+
return result;
|
|
1748
|
+
}
|
|
1749
|
+
const direction = ctx.direction || "forward";
|
|
1750
|
+
if (direction === "forward") {
|
|
1751
|
+
const transformed = def.transform(result.value, result);
|
|
1752
|
+
if (transformed instanceof Promise) {
|
|
1753
|
+
return transformed.then((value) => handleCodecTxResult(result, value, def.out, ctx));
|
|
1754
|
+
}
|
|
1755
|
+
return handleCodecTxResult(result, transformed, def.out, ctx);
|
|
1756
|
+
}
|
|
1757
|
+
else {
|
|
1758
|
+
const transformed = def.reverseTransform(result.value, result);
|
|
1759
|
+
if (transformed instanceof Promise) {
|
|
1760
|
+
return transformed.then((value) => handleCodecTxResult(result, value, def.in, ctx));
|
|
1761
|
+
}
|
|
1762
|
+
return handleCodecTxResult(result, transformed, def.in, ctx);
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
function handleCodecTxResult(left, value, nextSchema, ctx) {
|
|
1766
|
+
// Check if transform added any issues
|
|
1608
1767
|
if (left.issues.length) {
|
|
1768
|
+
left.aborted = true;
|
|
1609
1769
|
return left;
|
|
1610
1770
|
}
|
|
1611
|
-
return
|
|
1771
|
+
return nextSchema._zod.run({ value, issues: left.issues }, ctx);
|
|
1612
1772
|
}
|
|
1613
1773
|
exports.$ZodReadonly = core.$constructor("$ZodReadonly", (inst, def) => {
|
|
1614
1774
|
exports.$ZodType.init(inst, def);
|
|
@@ -1617,6 +1777,9 @@ exports.$ZodReadonly = core.$constructor("$ZodReadonly", (inst, def) => {
|
|
|
1617
1777
|
util.defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
|
|
1618
1778
|
util.defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
|
1619
1779
|
inst._zod.parse = (payload, ctx) => {
|
|
1780
|
+
if (ctx.direction === "backward") {
|
|
1781
|
+
return def.innerType._zod.run(payload, ctx);
|
|
1782
|
+
}
|
|
1620
1783
|
const result = def.innerType._zod.run(payload, ctx);
|
|
1621
1784
|
if (result instanceof Promise) {
|
|
1622
1785
|
return result.then(handleReadonlyResult);
|
|
@@ -1677,6 +1840,85 @@ exports.$ZodTemplateLiteral = core.$constructor("$ZodTemplateLiteral", (inst, de
|
|
|
1677
1840
|
return payload;
|
|
1678
1841
|
};
|
|
1679
1842
|
});
|
|
1843
|
+
exports.$ZodFunction = core.$constructor("$ZodFunction", (inst, def) => {
|
|
1844
|
+
exports.$ZodType.init(inst, def);
|
|
1845
|
+
inst._def = def;
|
|
1846
|
+
inst._zod.def = def;
|
|
1847
|
+
inst.implement = (func) => {
|
|
1848
|
+
if (typeof func !== "function") {
|
|
1849
|
+
throw new Error("implement() must be called with a function");
|
|
1850
|
+
}
|
|
1851
|
+
return function (...args) {
|
|
1852
|
+
const parsedArgs = inst._def.input ? (0, parse_js_1.parse)(inst._def.input, args) : args;
|
|
1853
|
+
const result = Reflect.apply(func, this, parsedArgs);
|
|
1854
|
+
if (inst._def.output) {
|
|
1855
|
+
return (0, parse_js_1.parse)(inst._def.output, result);
|
|
1856
|
+
}
|
|
1857
|
+
return result;
|
|
1858
|
+
};
|
|
1859
|
+
};
|
|
1860
|
+
inst.implementAsync = (func) => {
|
|
1861
|
+
if (typeof func !== "function") {
|
|
1862
|
+
throw new Error("implementAsync() must be called with a function");
|
|
1863
|
+
}
|
|
1864
|
+
return async function (...args) {
|
|
1865
|
+
const parsedArgs = inst._def.input ? await (0, parse_js_1.parseAsync)(inst._def.input, args) : args;
|
|
1866
|
+
const result = await Reflect.apply(func, this, parsedArgs);
|
|
1867
|
+
if (inst._def.output) {
|
|
1868
|
+
return await (0, parse_js_1.parseAsync)(inst._def.output, result);
|
|
1869
|
+
}
|
|
1870
|
+
return result;
|
|
1871
|
+
};
|
|
1872
|
+
};
|
|
1873
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
1874
|
+
if (typeof payload.value !== "function") {
|
|
1875
|
+
payload.issues.push({
|
|
1876
|
+
code: "invalid_type",
|
|
1877
|
+
expected: "function",
|
|
1878
|
+
input: payload.value,
|
|
1879
|
+
inst,
|
|
1880
|
+
});
|
|
1881
|
+
return payload;
|
|
1882
|
+
}
|
|
1883
|
+
// Check if output is a promise type to determine if we should use async implementation
|
|
1884
|
+
const hasPromiseOutput = inst._def.output && inst._def.output._zod.def.type === "promise";
|
|
1885
|
+
if (hasPromiseOutput) {
|
|
1886
|
+
payload.value = inst.implementAsync(payload.value);
|
|
1887
|
+
}
|
|
1888
|
+
else {
|
|
1889
|
+
payload.value = inst.implement(payload.value);
|
|
1890
|
+
}
|
|
1891
|
+
return payload;
|
|
1892
|
+
};
|
|
1893
|
+
inst.input = (...args) => {
|
|
1894
|
+
const F = inst.constructor;
|
|
1895
|
+
if (Array.isArray(args[0])) {
|
|
1896
|
+
return new F({
|
|
1897
|
+
type: "function",
|
|
1898
|
+
input: new exports.$ZodTuple({
|
|
1899
|
+
type: "tuple",
|
|
1900
|
+
items: args[0],
|
|
1901
|
+
rest: args[1],
|
|
1902
|
+
}),
|
|
1903
|
+
output: inst._def.output,
|
|
1904
|
+
});
|
|
1905
|
+
}
|
|
1906
|
+
return new F({
|
|
1907
|
+
type: "function",
|
|
1908
|
+
input: args[0],
|
|
1909
|
+
output: inst._def.output,
|
|
1910
|
+
});
|
|
1911
|
+
};
|
|
1912
|
+
inst.output = (output) => {
|
|
1913
|
+
const F = inst.constructor;
|
|
1914
|
+
return new F({
|
|
1915
|
+
type: "function",
|
|
1916
|
+
input: inst._def.input,
|
|
1917
|
+
output,
|
|
1918
|
+
});
|
|
1919
|
+
};
|
|
1920
|
+
return inst;
|
|
1921
|
+
});
|
|
1680
1922
|
exports.$ZodPromise = core.$constructor("$ZodPromise", (inst, def) => {
|
|
1681
1923
|
exports.$ZodType.init(inst, def);
|
|
1682
1924
|
inst._zod.parse = (payload, ctx) => {
|
package/v4/core/schemas.d.cts
CHANGED
|
@@ -15,14 +15,18 @@ export interface ParseContext<T extends errors.$ZodIssueBase = never> {
|
|
|
15
15
|
/** @internal */
|
|
16
16
|
export interface ParseContextInternal<T extends errors.$ZodIssueBase = never> extends ParseContext<T> {
|
|
17
17
|
readonly async?: boolean | undefined;
|
|
18
|
+
readonly direction?: "forward" | "backward";
|
|
19
|
+
readonly skipChecks?: boolean;
|
|
18
20
|
}
|
|
19
21
|
export interface ParsePayload<T = unknown> {
|
|
20
22
|
value: T;
|
|
21
23
|
issues: errors.$ZodRawIssue[];
|
|
24
|
+
/** A may to mark a whole payload as aborted. Used in codecs/pipes. */
|
|
25
|
+
aborted?: boolean;
|
|
22
26
|
}
|
|
23
27
|
export type CheckFn<T> = (input: ParsePayload<T>) => util.MaybeAsync<void>;
|
|
24
28
|
export interface $ZodTypeDef {
|
|
25
|
-
type: "string" | "number" | "int" | "boolean" | "bigint" | "symbol" | "null" | "undefined" | "void" | "never" | "any" | "unknown" | "date" | "object" | "record" | "file" | "array" | "tuple" | "union" | "intersection" | "map" | "set" | "enum" | "literal" | "nullable" | "optional" | "nonoptional" | "success" | "transform" | "default" | "prefault" | "catch" | "nan" | "pipe" | "readonly" | "template_literal" | "promise" | "lazy" | "custom";
|
|
29
|
+
type: "string" | "number" | "int" | "boolean" | "bigint" | "symbol" | "null" | "undefined" | "void" | "never" | "any" | "unknown" | "date" | "object" | "record" | "file" | "array" | "tuple" | "union" | "intersection" | "map" | "set" | "enum" | "literal" | "nullable" | "optional" | "nonoptional" | "success" | "transform" | "default" | "prefault" | "catch" | "nan" | "pipe" | "readonly" | "template_literal" | "promise" | "lazy" | "function" | "custom";
|
|
26
30
|
error?: errors.$ZodErrorMap<never> | undefined;
|
|
27
31
|
checks?: checks.$ZodCheck<never>[];
|
|
28
32
|
}
|
|
@@ -597,6 +601,7 @@ out Shape extends Readonly<$ZodShape> = Readonly<$ZodShape>, out Params extends
|
|
|
597
601
|
"~standard": $ZodStandardSchema<this>;
|
|
598
602
|
}
|
|
599
603
|
export declare const $ZodObject: core.$constructor<$ZodObject>;
|
|
604
|
+
export declare const $ZodObjectJIT: core.$constructor<$ZodObject>;
|
|
600
605
|
export type $InferUnionOutput<T extends SomeType> = T extends any ? core.output<T> : never;
|
|
601
606
|
export type $InferUnionInput<T extends SomeType> = T extends any ? core.input<T> : never;
|
|
602
607
|
export interface $ZodUnionDef<Options extends readonly SomeType[] = readonly $ZodType[]> extends $ZodTypeDef {
|
|
@@ -939,6 +944,10 @@ export interface $ZodPipeDef<A extends SomeType = $ZodType, B extends SomeType =
|
|
|
939
944
|
type: "pipe";
|
|
940
945
|
in: A;
|
|
941
946
|
out: B;
|
|
947
|
+
/** Only defined inside $ZodCodec instances. */
|
|
948
|
+
transform?: (value: core.output<A>, payload: ParsePayload<core.output<A>>) => core.input<B>;
|
|
949
|
+
/** Only defined inside $ZodCodec instances. */
|
|
950
|
+
reverseTransform?: (value: core.input<B>, payload: ParsePayload<core.input<B>>) => core.output<A>;
|
|
942
951
|
}
|
|
943
952
|
export interface $ZodPipeInternals<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodTypeInternals<core.output<B>, core.input<A>> {
|
|
944
953
|
def: $ZodPipeDef<A, B>;
|
|
@@ -952,6 +961,22 @@ export interface $ZodPipe<A extends SomeType = $ZodType, B extends SomeType = $Z
|
|
|
952
961
|
_zod: $ZodPipeInternals<A, B>;
|
|
953
962
|
}
|
|
954
963
|
export declare const $ZodPipe: core.$constructor<$ZodPipe>;
|
|
964
|
+
export interface $ZodCodecDef<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodPipeDef<A, B> {
|
|
965
|
+
transform: (value: core.output<A>, payload: ParsePayload<core.output<A>>) => core.input<B>;
|
|
966
|
+
reverseTransform: (value: core.input<B>, payload: ParsePayload<core.input<B>>) => core.output<A>;
|
|
967
|
+
}
|
|
968
|
+
export interface $ZodCodecInternals<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodTypeInternals<core.output<B>, core.input<A>> {
|
|
969
|
+
def: $ZodCodecDef<A, B>;
|
|
970
|
+
isst: never;
|
|
971
|
+
values: A["_zod"]["values"];
|
|
972
|
+
optin: A["_zod"]["optin"];
|
|
973
|
+
optout: B["_zod"]["optout"];
|
|
974
|
+
propValues: A["_zod"]["propValues"];
|
|
975
|
+
}
|
|
976
|
+
export interface $ZodCodec<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodType {
|
|
977
|
+
_zod: $ZodCodecInternals<A, B>;
|
|
978
|
+
}
|
|
979
|
+
export declare const $ZodCodec: core.$constructor<$ZodCodec>;
|
|
955
980
|
export interface $ZodReadonlyDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
|
956
981
|
type: "readonly";
|
|
957
982
|
innerType: T;
|
|
@@ -1001,6 +1026,39 @@ export type ConvertPartsToStringTuple<Parts extends $ZodTemplateLiteralPart[]> =
|
|
|
1001
1026
|
export type ToTemplateLiteral<Parts extends $ZodTemplateLiteralPart[]> = ConcatenateTupleOfStrings<ConvertPartsToStringTuple<Parts>>;
|
|
1002
1027
|
export type $PartsToTemplateLiteral<Parts extends $ZodTemplateLiteralPart[]> = [] extends Parts ? `` : Parts extends [...infer Rest, infer Last extends $ZodTemplateLiteralPart] ? Rest extends $ZodTemplateLiteralPart[] ? AppendToTemplateLiteral<$PartsToTemplateLiteral<Rest>, Last> : never : never;
|
|
1003
1028
|
export declare const $ZodTemplateLiteral: core.$constructor<$ZodTemplateLiteral>;
|
|
1029
|
+
export type $ZodFunctionArgs = $ZodType<unknown[], unknown[]>;
|
|
1030
|
+
export type $ZodFunctionIn = $ZodFunctionArgs;
|
|
1031
|
+
export type $ZodFunctionOut = $ZodType;
|
|
1032
|
+
export type $InferInnerFunctionType<Args extends $ZodFunctionIn, Returns extends $ZodFunctionOut> = (...args: $ZodFunctionIn extends Args ? never[] : core.output<Args>) => core.input<Returns>;
|
|
1033
|
+
export type $InferInnerFunctionTypeAsync<Args extends $ZodFunctionIn, Returns extends $ZodFunctionOut> = (...args: $ZodFunctionIn extends Args ? never[] : core.output<Args>) => util.MaybeAsync<core.input<Returns>>;
|
|
1034
|
+
export type $InferOuterFunctionType<Args extends $ZodFunctionIn, Returns extends $ZodFunctionOut> = (...args: $ZodFunctionIn extends Args ? never[] : core.input<Args>) => core.output<Returns>;
|
|
1035
|
+
export type $InferOuterFunctionTypeAsync<Args extends $ZodFunctionIn, Returns extends $ZodFunctionOut> = (...args: $ZodFunctionIn extends Args ? never[] : core.input<Args>) => util.MaybeAsync<core.output<Returns>>;
|
|
1036
|
+
export interface $ZodFunctionDef<In extends $ZodFunctionIn = $ZodFunctionIn, Out extends $ZodFunctionOut = $ZodFunctionOut> extends $ZodTypeDef {
|
|
1037
|
+
type: "function";
|
|
1038
|
+
input: In;
|
|
1039
|
+
output: Out;
|
|
1040
|
+
}
|
|
1041
|
+
export interface $ZodFunctionInternals<Args extends $ZodFunctionIn, Returns extends $ZodFunctionOut> extends $ZodTypeInternals<$InferOuterFunctionType<Args, Returns>, $InferInnerFunctionType<Args, Returns>> {
|
|
1042
|
+
def: $ZodFunctionDef<Args, Returns>;
|
|
1043
|
+
isst: errors.$ZodIssueInvalidType;
|
|
1044
|
+
}
|
|
1045
|
+
export interface $ZodFunction<Args extends $ZodFunctionIn = $ZodFunctionIn, Returns extends $ZodFunctionOut = $ZodFunctionOut> extends $ZodType<any, any, $ZodFunctionInternals<Args, Returns>> {
|
|
1046
|
+
/** @deprecated */
|
|
1047
|
+
_def: $ZodFunctionDef<Args, Returns>;
|
|
1048
|
+
_input: $InferInnerFunctionType<Args, Returns>;
|
|
1049
|
+
_output: $InferOuterFunctionType<Args, Returns>;
|
|
1050
|
+
implement<F extends $InferInnerFunctionType<Args, Returns>>(func: F): (...args: Parameters<this["_output"]>) => ReturnType<F> extends ReturnType<this["_output"]> ? ReturnType<F> : ReturnType<this["_output"]>;
|
|
1051
|
+
implementAsync<F extends $InferInnerFunctionTypeAsync<Args, Returns>>(func: F): F extends $InferOuterFunctionTypeAsync<Args, Returns> ? F : $InferOuterFunctionTypeAsync<Args, Returns>;
|
|
1052
|
+
input<const Items extends util.TupleItems, const Rest extends $ZodFunctionOut = $ZodFunctionOut>(args: Items, rest?: Rest): $ZodFunction<$ZodTuple<Items, Rest>, Returns>;
|
|
1053
|
+
input<NewArgs extends $ZodFunctionIn>(args: NewArgs): $ZodFunction<NewArgs, Returns>;
|
|
1054
|
+
input(...args: any[]): $ZodFunction<any, Returns>;
|
|
1055
|
+
output<NewReturns extends $ZodType>(output: NewReturns): $ZodFunction<Args, NewReturns>;
|
|
1056
|
+
}
|
|
1057
|
+
export interface $ZodFunctionParams<I extends $ZodFunctionIn, O extends $ZodType> {
|
|
1058
|
+
input?: I;
|
|
1059
|
+
output?: O;
|
|
1060
|
+
}
|
|
1061
|
+
export declare const $ZodFunction: core.$constructor<$ZodFunction>;
|
|
1004
1062
|
export interface $ZodPromiseDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
|
1005
1063
|
type: "promise";
|
|
1006
1064
|
innerType: T;
|
|
@@ -1051,5 +1109,5 @@ export interface $ZodCustom<O = unknown, I = unknown> extends $ZodType {
|
|
|
1051
1109
|
_zod: $ZodCustomInternals<O, I>;
|
|
1052
1110
|
}
|
|
1053
1111
|
export declare const $ZodCustom: core.$constructor<$ZodCustom>;
|
|
1054
|
-
export type $ZodTypes = $ZodString | $ZodNumber | $ZodBigInt | $ZodBoolean | $ZodDate | $ZodSymbol | $ZodUndefined | $ZodNullable | $ZodNull | $ZodAny | $ZodUnknown | $ZodNever | $ZodVoid | $ZodArray | $ZodObject | $ZodUnion | $ZodIntersection | $ZodTuple | $ZodRecord | $ZodMap | $ZodSet | $ZodLiteral | $ZodEnum | $ZodPromise | $ZodLazy | $ZodOptional | $ZodDefault | $ZodPrefault | $ZodTemplateLiteral | $ZodCustom | $ZodTransform | $ZodNonOptional | $ZodReadonly | $ZodNaN | $ZodPipe | $ZodSuccess | $ZodCatch | $ZodFile;
|
|
1055
|
-
export type $ZodStringFormatTypes = $ZodGUID | $ZodUUID | $ZodEmail | $ZodURL | $ZodEmoji | $ZodNanoID | $ZodCUID | $ZodCUID2 | $ZodULID | $ZodXID | $ZodKSUID | $ZodISODateTime | $ZodISODate | $ZodISOTime | $ZodISODuration | $ZodIPv4 | $ZodIPv6 | $ZodCIDRv4 | $ZodCIDRv6 | $ZodBase64 | $ZodBase64URL | $ZodE164 | $ZodJWT
|
|
1112
|
+
export type $ZodTypes = $ZodString | $ZodNumber | $ZodBigInt | $ZodBoolean | $ZodDate | $ZodSymbol | $ZodUndefined | $ZodNullable | $ZodNull | $ZodAny | $ZodUnknown | $ZodNever | $ZodVoid | $ZodArray | $ZodObject | $ZodUnion | $ZodIntersection | $ZodTuple | $ZodRecord | $ZodMap | $ZodSet | $ZodLiteral | $ZodEnum | $ZodFunction | $ZodPromise | $ZodLazy | $ZodOptional | $ZodDefault | $ZodPrefault | $ZodTemplateLiteral | $ZodCustom | $ZodTransform | $ZodNonOptional | $ZodReadonly | $ZodNaN | $ZodPipe | $ZodSuccess | $ZodCatch | $ZodFile;
|
|
1113
|
+
export type $ZodStringFormatTypes = $ZodGUID | $ZodUUID | $ZodEmail | $ZodURL | $ZodEmoji | $ZodNanoID | $ZodCUID | $ZodCUID2 | $ZodULID | $ZodXID | $ZodKSUID | $ZodISODateTime | $ZodISODate | $ZodISOTime | $ZodISODuration | $ZodIPv4 | $ZodIPv6 | $ZodCIDRv4 | $ZodCIDRv6 | $ZodBase64 | $ZodBase64URL | $ZodE164 | $ZodJWT | $ZodCustomStringFormat<"hex"> | $ZodCustomStringFormat<util.HashFormat> | $ZodCustomStringFormat<"hostname">;
|