zod 4.1.0-canary.20250821T014930 → 4.1.0-canary.20250823T064644
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/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/v4/classic/external.cjs +1 -2
- 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/parse.cjs +10 -1
- 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 +59 -4
- 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 +19 -24
- 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/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/index.cjs +0 -1
- 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 +45 -1
- 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 +309 -77
- 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/mini/external.cjs +1 -2
- 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/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 +58 -3
- 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/classic/schemas.cjs
CHANGED
|
@@ -24,7 +24,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
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;
|
|
27
|
+
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
28
|
exports.string = string;
|
|
29
29
|
exports.email = email;
|
|
30
30
|
exports.guid = guid;
|
|
@@ -33,6 +33,7 @@ exports.uuidv4 = uuidv4;
|
|
|
33
33
|
exports.uuidv6 = uuidv6;
|
|
34
34
|
exports.uuidv7 = uuidv7;
|
|
35
35
|
exports.url = url;
|
|
36
|
+
exports.httpUrl = httpUrl;
|
|
36
37
|
exports.emoji = emoji;
|
|
37
38
|
exports.nanoid = nanoid;
|
|
38
39
|
exports.cuid = cuid;
|
|
@@ -50,6 +51,8 @@ exports.e164 = e164;
|
|
|
50
51
|
exports.jwt = jwt;
|
|
51
52
|
exports.stringFormat = stringFormat;
|
|
52
53
|
exports.hostname = hostname;
|
|
54
|
+
exports.hex = hex;
|
|
55
|
+
exports.hash = hash;
|
|
53
56
|
exports.number = number;
|
|
54
57
|
exports.int = int;
|
|
55
58
|
exports.float32 = float32;
|
|
@@ -96,10 +99,15 @@ exports.success = success;
|
|
|
96
99
|
exports.catch = _catch;
|
|
97
100
|
exports.nan = nan;
|
|
98
101
|
exports.pipe = pipe;
|
|
102
|
+
exports.codec = codec;
|
|
99
103
|
exports.readonly = readonly;
|
|
100
104
|
exports.templateLiteral = templateLiteral;
|
|
101
105
|
exports.lazy = lazy;
|
|
102
106
|
exports.promise = promise;
|
|
107
|
+
exports._function = _function;
|
|
108
|
+
exports.function = _function;
|
|
109
|
+
exports._function = _function;
|
|
110
|
+
exports.function = _function;
|
|
103
111
|
exports.check = check;
|
|
104
112
|
exports.custom = custom;
|
|
105
113
|
exports.refine = refine;
|
|
@@ -292,6 +300,13 @@ exports.ZodURL = core.$constructor("ZodURL", (inst, def) => {
|
|
|
292
300
|
function url(params) {
|
|
293
301
|
return core._url(exports.ZodURL, params);
|
|
294
302
|
}
|
|
303
|
+
function httpUrl(params) {
|
|
304
|
+
return core._url(exports.ZodURL, {
|
|
305
|
+
protocol: /^https?$/,
|
|
306
|
+
hostname: core.regexes.domain,
|
|
307
|
+
...index_js_1.util.normalizeParams(params),
|
|
308
|
+
});
|
|
309
|
+
}
|
|
295
310
|
exports.ZodEmoji = core.$constructor("ZodEmoji", (inst, def) => {
|
|
296
311
|
// ZodStringFormat.init(inst, def);
|
|
297
312
|
core.$ZodEmoji.init(inst, def);
|
|
@@ -421,6 +436,17 @@ function stringFormat(format, fnOrRegex, _params = {}) {
|
|
|
421
436
|
function hostname(_params) {
|
|
422
437
|
return core._stringFormat(exports.ZodCustomStringFormat, "hostname", core.regexes.hostname, _params);
|
|
423
438
|
}
|
|
439
|
+
function hex(_params) {
|
|
440
|
+
return core._stringFormat(exports.ZodCustomStringFormat, "hex", core.regexes.hex, _params);
|
|
441
|
+
}
|
|
442
|
+
function hash(alg, params) {
|
|
443
|
+
const enc = params?.enc ?? "hex";
|
|
444
|
+
const format = `${alg}_${enc}`;
|
|
445
|
+
const regex = core.regexes[format];
|
|
446
|
+
if (!regex)
|
|
447
|
+
throw new Error(`Unrecognized hash format: ${format}`);
|
|
448
|
+
return core._stringFormat(exports.ZodCustomStringFormat, format, regex, params);
|
|
449
|
+
}
|
|
424
450
|
exports.ZodNumber = core.$constructor("ZodNumber", (inst, def) => {
|
|
425
451
|
core.$ZodNumber.init(inst, def);
|
|
426
452
|
exports.ZodType.init(inst, def);
|
|
@@ -594,7 +620,7 @@ function keyof(schema) {
|
|
|
594
620
|
return _enum(Object.keys(shape));
|
|
595
621
|
}
|
|
596
622
|
exports.ZodObject = core.$constructor("ZodObject", (inst, def) => {
|
|
597
|
-
core.$
|
|
623
|
+
core.$ZodObjectJIT.init(inst, def);
|
|
598
624
|
exports.ZodType.init(inst, def);
|
|
599
625
|
index_js_1.util.defineLazy(inst, "shape", () => def.shape);
|
|
600
626
|
inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
|
|
@@ -606,6 +632,9 @@ exports.ZodObject = core.$constructor("ZodObject", (inst, def) => {
|
|
|
606
632
|
inst.extend = (incoming) => {
|
|
607
633
|
return index_js_1.util.extend(inst, incoming);
|
|
608
634
|
};
|
|
635
|
+
inst.safeExtend = (incoming) => {
|
|
636
|
+
return index_js_1.util.safeExtend(inst, incoming);
|
|
637
|
+
};
|
|
609
638
|
inst.merge = (other) => index_js_1.util.merge(inst, other);
|
|
610
639
|
inst.pick = (mask) => index_js_1.util.pick(inst, mask);
|
|
611
640
|
inst.omit = (mask) => index_js_1.util.omit(inst, mask);
|
|
@@ -851,6 +880,9 @@ exports.ZodTransform = core.$constructor("ZodTransform", (inst, def) => {
|
|
|
851
880
|
core.$ZodTransform.init(inst, def);
|
|
852
881
|
exports.ZodType.init(inst, def);
|
|
853
882
|
inst._zod.parse = (payload, _ctx) => {
|
|
883
|
+
if (_ctx.direction === "backward") {
|
|
884
|
+
throw new core.$ZodEncodeError(inst.constructor.name);
|
|
885
|
+
}
|
|
854
886
|
payload.addIssue = (issue) => {
|
|
855
887
|
if (typeof issue === "string") {
|
|
856
888
|
payload.issues.push(index_js_1.util.issue(issue, payload.value, def));
|
|
@@ -996,6 +1028,19 @@ function pipe(in_, out) {
|
|
|
996
1028
|
// ...util.normalizeParams(params),
|
|
997
1029
|
});
|
|
998
1030
|
}
|
|
1031
|
+
exports.ZodCodec = core.$constructor("ZodCodec", (inst, def) => {
|
|
1032
|
+
exports.ZodPipe.init(inst, def);
|
|
1033
|
+
core.$ZodCodec.init(inst, def);
|
|
1034
|
+
});
|
|
1035
|
+
function codec(in_, out, params) {
|
|
1036
|
+
return new exports.ZodCodec({
|
|
1037
|
+
type: "pipe",
|
|
1038
|
+
in: in_,
|
|
1039
|
+
out: out,
|
|
1040
|
+
transform: params.decode,
|
|
1041
|
+
reverseTransform: params.encode,
|
|
1042
|
+
});
|
|
1043
|
+
}
|
|
999
1044
|
exports.ZodReadonly = core.$constructor("ZodReadonly", (inst, def) => {
|
|
1000
1045
|
core.$ZodReadonly.init(inst, def);
|
|
1001
1046
|
exports.ZodType.init(inst, def);
|
|
@@ -1040,6 +1085,17 @@ function promise(innerType) {
|
|
|
1040
1085
|
innerType: innerType,
|
|
1041
1086
|
});
|
|
1042
1087
|
}
|
|
1088
|
+
exports.ZodFunction = core.$constructor("ZodFunction", (inst, def) => {
|
|
1089
|
+
core.$ZodFunction.init(inst, def);
|
|
1090
|
+
exports.ZodType.init(inst, def);
|
|
1091
|
+
});
|
|
1092
|
+
function _function(params) {
|
|
1093
|
+
return new exports.ZodFunction({
|
|
1094
|
+
type: "function",
|
|
1095
|
+
input: Array.isArray(params?.input) ? tuple(params?.input) : (params?.input ?? array(unknown())),
|
|
1096
|
+
output: params?.output ?? unknown(),
|
|
1097
|
+
});
|
|
1098
|
+
}
|
|
1043
1099
|
exports.ZodCustom = core.$constructor("ZodCustom", (inst, def) => {
|
|
1044
1100
|
core.$ZodCustom.init(inst, def);
|
|
1045
1101
|
exports.ZodType.init(inst, def);
|
|
@@ -1078,10 +1134,9 @@ function _instanceof(cls, params = {
|
|
|
1078
1134
|
}
|
|
1079
1135
|
// stringbool
|
|
1080
1136
|
const stringbool = (...args) => core._stringbool({
|
|
1081
|
-
|
|
1137
|
+
Codec: exports.ZodCodec,
|
|
1082
1138
|
Boolean: exports.ZodBoolean,
|
|
1083
1139
|
String: exports.ZodString,
|
|
1084
|
-
Transform: exports.ZodTransform,
|
|
1085
1140
|
}, ...args);
|
|
1086
1141
|
exports.stringbool = stringbool;
|
|
1087
1142
|
function json(params) {
|
package/v4/classic/schemas.d.cts
CHANGED
|
@@ -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) =>
|
|
647
|
+
export declare const stringbool: (_params?: string | core.$ZodStringBoolParams) => ZodCodec<ZodString, ZodBoolean>;
|
|
602
648
|
type _ZodJSONSchema = ZodUnion<[
|
|
603
649
|
ZodString,
|
|
604
650
|
ZodNumber,
|
package/v4/classic/schemas.d.ts
CHANGED
|
@@ -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) =>
|
|
647
|
+
export declare const stringbool: (_params?: string | core.$ZodStringBoolParams) => ZodCodec<ZodString, ZodBoolean>;
|
|
602
648
|
type _ZodJSONSchema = ZodUnion<[
|
|
603
649
|
ZodString,
|
|
604
650
|
ZodNumber,
|
package/v4/classic/schemas.js
CHANGED
|
@@ -183,6 +183,13 @@ export const ZodURL = /*@__PURE__*/ core.$constructor("ZodURL", (inst, def) => {
|
|
|
183
183
|
export function url(params) {
|
|
184
184
|
return core._url(ZodURL, params);
|
|
185
185
|
}
|
|
186
|
+
export function httpUrl(params) {
|
|
187
|
+
return core._url(ZodURL, {
|
|
188
|
+
protocol: /^https?$/,
|
|
189
|
+
hostname: core.regexes.domain,
|
|
190
|
+
...util.normalizeParams(params),
|
|
191
|
+
});
|
|
192
|
+
}
|
|
186
193
|
export const ZodEmoji = /*@__PURE__*/ core.$constructor("ZodEmoji", (inst, def) => {
|
|
187
194
|
// ZodStringFormat.init(inst, def);
|
|
188
195
|
core.$ZodEmoji.init(inst, def);
|
|
@@ -312,6 +319,17 @@ export function stringFormat(format, fnOrRegex, _params = {}) {
|
|
|
312
319
|
export function hostname(_params) {
|
|
313
320
|
return core._stringFormat(ZodCustomStringFormat, "hostname", core.regexes.hostname, _params);
|
|
314
321
|
}
|
|
322
|
+
export function hex(_params) {
|
|
323
|
+
return core._stringFormat(ZodCustomStringFormat, "hex", core.regexes.hex, _params);
|
|
324
|
+
}
|
|
325
|
+
export function hash(alg, params) {
|
|
326
|
+
const enc = params?.enc ?? "hex";
|
|
327
|
+
const format = `${alg}_${enc}`;
|
|
328
|
+
const regex = core.regexes[format];
|
|
329
|
+
if (!regex)
|
|
330
|
+
throw new Error(`Unrecognized hash format: ${format}`);
|
|
331
|
+
return core._stringFormat(ZodCustomStringFormat, format, regex, params);
|
|
332
|
+
}
|
|
315
333
|
export const ZodNumber = /*@__PURE__*/ core.$constructor("ZodNumber", (inst, def) => {
|
|
316
334
|
core.$ZodNumber.init(inst, def);
|
|
317
335
|
ZodType.init(inst, def);
|
|
@@ -488,7 +506,7 @@ export function keyof(schema) {
|
|
|
488
506
|
return _enum(Object.keys(shape));
|
|
489
507
|
}
|
|
490
508
|
export const ZodObject = /*@__PURE__*/ core.$constructor("ZodObject", (inst, def) => {
|
|
491
|
-
core.$
|
|
509
|
+
core.$ZodObjectJIT.init(inst, def);
|
|
492
510
|
ZodType.init(inst, def);
|
|
493
511
|
util.defineLazy(inst, "shape", () => def.shape);
|
|
494
512
|
inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
|
|
@@ -500,6 +518,9 @@ export const ZodObject = /*@__PURE__*/ core.$constructor("ZodObject", (inst, def
|
|
|
500
518
|
inst.extend = (incoming) => {
|
|
501
519
|
return util.extend(inst, incoming);
|
|
502
520
|
};
|
|
521
|
+
inst.safeExtend = (incoming) => {
|
|
522
|
+
return util.safeExtend(inst, incoming);
|
|
523
|
+
};
|
|
503
524
|
inst.merge = (other) => util.merge(inst, other);
|
|
504
525
|
inst.pick = (mask) => util.pick(inst, mask);
|
|
505
526
|
inst.omit = (mask) => util.omit(inst, mask);
|
|
@@ -746,6 +767,9 @@ export const ZodTransform = /*@__PURE__*/ core.$constructor("ZodTransform", (ins
|
|
|
746
767
|
core.$ZodTransform.init(inst, def);
|
|
747
768
|
ZodType.init(inst, def);
|
|
748
769
|
inst._zod.parse = (payload, _ctx) => {
|
|
770
|
+
if (_ctx.direction === "backward") {
|
|
771
|
+
throw new core.$ZodEncodeError(inst.constructor.name);
|
|
772
|
+
}
|
|
749
773
|
payload.addIssue = (issue) => {
|
|
750
774
|
if (typeof issue === "string") {
|
|
751
775
|
payload.issues.push(util.issue(issue, payload.value, def));
|
|
@@ -892,6 +916,19 @@ export function pipe(in_, out) {
|
|
|
892
916
|
// ...util.normalizeParams(params),
|
|
893
917
|
});
|
|
894
918
|
}
|
|
919
|
+
export const ZodCodec = /*@__PURE__*/ core.$constructor("ZodCodec", (inst, def) => {
|
|
920
|
+
ZodPipe.init(inst, def);
|
|
921
|
+
core.$ZodCodec.init(inst, def);
|
|
922
|
+
});
|
|
923
|
+
export function codec(in_, out, params) {
|
|
924
|
+
return new ZodCodec({
|
|
925
|
+
type: "pipe",
|
|
926
|
+
in: in_,
|
|
927
|
+
out: out,
|
|
928
|
+
transform: params.decode,
|
|
929
|
+
reverseTransform: params.encode,
|
|
930
|
+
});
|
|
931
|
+
}
|
|
895
932
|
export const ZodReadonly = /*@__PURE__*/ core.$constructor("ZodReadonly", (inst, def) => {
|
|
896
933
|
core.$ZodReadonly.init(inst, def);
|
|
897
934
|
ZodType.init(inst, def);
|
|
@@ -936,6 +973,18 @@ export function promise(innerType) {
|
|
|
936
973
|
innerType: innerType,
|
|
937
974
|
});
|
|
938
975
|
}
|
|
976
|
+
export const ZodFunction = /*@__PURE__*/ core.$constructor("ZodFunction", (inst, def) => {
|
|
977
|
+
core.$ZodFunction.init(inst, def);
|
|
978
|
+
ZodType.init(inst, def);
|
|
979
|
+
});
|
|
980
|
+
export function _function(params) {
|
|
981
|
+
return new ZodFunction({
|
|
982
|
+
type: "function",
|
|
983
|
+
input: Array.isArray(params?.input) ? tuple(params?.input) : (params?.input ?? array(unknown())),
|
|
984
|
+
output: params?.output ?? unknown(),
|
|
985
|
+
});
|
|
986
|
+
}
|
|
987
|
+
export { _function as function };
|
|
939
988
|
export const ZodCustom = /*@__PURE__*/ core.$constructor("ZodCustom", (inst, def) => {
|
|
940
989
|
core.$ZodCustom.init(inst, def);
|
|
941
990
|
ZodType.init(inst, def);
|
|
@@ -975,10 +1024,9 @@ function _instanceof(cls, params = {
|
|
|
975
1024
|
export { _instanceof as instanceof };
|
|
976
1025
|
// stringbool
|
|
977
1026
|
export const stringbool = (...args) => core._stringbool({
|
|
978
|
-
|
|
1027
|
+
Codec: ZodCodec,
|
|
979
1028
|
Boolean: ZodBoolean,
|
|
980
1029
|
String: ZodString,
|
|
981
|
-
Transform: ZodTransform,
|
|
982
1030
|
}, ...args);
|
|
983
1031
|
export function json(params) {
|
|
984
1032
|
const jsonSchema = lazy(() => {
|
package/v4/core/api.cjs
CHANGED
|
@@ -973,7 +973,7 @@ function _superRefine(fn) {
|
|
|
973
973
|
_issue.code ?? (_issue.code = "custom");
|
|
974
974
|
_issue.input ?? (_issue.input = payload.value);
|
|
975
975
|
_issue.inst ?? (_issue.inst = ch);
|
|
976
|
-
_issue.continue ?? (_issue.continue = !ch._zod.def.abort);
|
|
976
|
+
_issue.continue ?? (_issue.continue = !ch._zod.def.abort); // abort is always undefined, so this is always true...
|
|
977
977
|
payload.issues.push(util.issue(_issue));
|
|
978
978
|
}
|
|
979
979
|
};
|
|
@@ -999,13 +999,16 @@ function _stringbool(Classes, _params) {
|
|
|
999
999
|
}
|
|
1000
1000
|
const truthySet = new Set(truthyArray);
|
|
1001
1001
|
const falsySet = new Set(falsyArray);
|
|
1002
|
-
const
|
|
1002
|
+
const _Codec = Classes.Codec ?? schemas.$ZodCodec;
|
|
1003
1003
|
const _Boolean = Classes.Boolean ?? schemas.$ZodBoolean;
|
|
1004
1004
|
const _String = Classes.String ?? schemas.$ZodString;
|
|
1005
|
-
const
|
|
1006
|
-
const
|
|
1007
|
-
|
|
1008
|
-
|
|
1005
|
+
const stringSchema = new _String({ type: "string", error: params.error });
|
|
1006
|
+
const booleanSchema = new _Boolean({ type: "boolean", error: params.error });
|
|
1007
|
+
const codec = new _Codec({
|
|
1008
|
+
type: "pipe",
|
|
1009
|
+
in: stringSchema,
|
|
1010
|
+
out: booleanSchema,
|
|
1011
|
+
transform: ((input, payload) => {
|
|
1009
1012
|
let data = input;
|
|
1010
1013
|
if (params.case !== "sensitive")
|
|
1011
1014
|
data = data.toLowerCase();
|
|
@@ -1021,31 +1024,23 @@ function _stringbool(Classes, _params) {
|
|
|
1021
1024
|
expected: "stringbool",
|
|
1022
1025
|
values: [...truthySet, ...falsySet],
|
|
1023
1026
|
input: payload.value,
|
|
1024
|
-
inst:
|
|
1027
|
+
inst: codec,
|
|
1025
1028
|
continue: false,
|
|
1026
1029
|
});
|
|
1027
1030
|
return {};
|
|
1028
1031
|
}
|
|
1029
|
-
},
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
error: params.error,
|
|
1038
|
-
});
|
|
1039
|
-
const outerPipe = new _Pipe({
|
|
1040
|
-
type: "pipe",
|
|
1041
|
-
in: innerPipe,
|
|
1042
|
-
out: new _Boolean({
|
|
1043
|
-
type: "boolean",
|
|
1044
|
-
error: params.error,
|
|
1032
|
+
}),
|
|
1033
|
+
reverseTransform: ((input, _payload) => {
|
|
1034
|
+
if (input === true) {
|
|
1035
|
+
return truthyArray[0] || "true";
|
|
1036
|
+
}
|
|
1037
|
+
else {
|
|
1038
|
+
return falsyArray[0] || "false";
|
|
1039
|
+
}
|
|
1045
1040
|
}),
|
|
1046
1041
|
error: params.error,
|
|
1047
1042
|
});
|
|
1048
|
-
return
|
|
1043
|
+
return codec;
|
|
1049
1044
|
}
|
|
1050
1045
|
function _stringFormat(Class, format, fnOrRegex, _params = {}) {
|
|
1051
1046
|
const params = util.normalizeParams(_params);
|
package/v4/core/api.d.cts
CHANGED
|
@@ -269,7 +269,7 @@ export type $ZodSuperRefineIssue<T extends errors.$ZodIssueBase = errors.$ZodIss
|
|
|
269
269
|
type RawIssue<T extends errors.$ZodIssueBase> = T extends any ? util.Flatten<util.MakePartial<T, "message" | "path"> & {
|
|
270
270
|
/** The schema or check that originated this issue. */
|
|
271
271
|
readonly inst?: schemas.$ZodType | checks.$ZodCheck;
|
|
272
|
-
/** If `true`, Zod will
|
|
272
|
+
/** If `true`, Zod will execute subsequent checks/refinements instead of immediately aborting */
|
|
273
273
|
readonly continue?: boolean | undefined;
|
|
274
274
|
} & Record<string, unknown>> : never;
|
|
275
275
|
export interface $RefinementCtx<T = unknown> extends schemas.ParsePayload<T> {
|
|
@@ -288,9 +288,8 @@ export interface $ZodStringBoolParams extends TypeParams {
|
|
|
288
288
|
case?: "sensitive" | "insensitive" | undefined;
|
|
289
289
|
}
|
|
290
290
|
export declare function _stringbool(Classes: {
|
|
291
|
-
|
|
291
|
+
Codec?: typeof schemas.$ZodCodec;
|
|
292
292
|
Boolean?: typeof schemas.$ZodBoolean;
|
|
293
|
-
Transform?: typeof schemas.$ZodTransform;
|
|
294
293
|
String?: typeof schemas.$ZodString;
|
|
295
|
-
}, _params?: string | $ZodStringBoolParams): schemas.$
|
|
294
|
+
}, _params?: string | $ZodStringBoolParams): schemas.$ZodCodec<schemas.$ZodString, schemas.$ZodBoolean>;
|
|
296
295
|
export declare function _stringFormat<Format extends string>(Class: typeof schemas.$ZodCustomStringFormat, format: Format, fnOrRegex: ((arg: string) => util.MaybeAsync<unknown>) | RegExp, _params?: string | $ZodStringFormatParams): schemas.$ZodCustomStringFormat<Format>;
|
package/v4/core/api.d.ts
CHANGED
|
@@ -269,7 +269,7 @@ export type $ZodSuperRefineIssue<T extends errors.$ZodIssueBase = errors.$ZodIss
|
|
|
269
269
|
type RawIssue<T extends errors.$ZodIssueBase> = T extends any ? util.Flatten<util.MakePartial<T, "message" | "path"> & {
|
|
270
270
|
/** The schema or check that originated this issue. */
|
|
271
271
|
readonly inst?: schemas.$ZodType | checks.$ZodCheck;
|
|
272
|
-
/** If `true`, Zod will
|
|
272
|
+
/** If `true`, Zod will execute subsequent checks/refinements instead of immediately aborting */
|
|
273
273
|
readonly continue?: boolean | undefined;
|
|
274
274
|
} & Record<string, unknown>> : never;
|
|
275
275
|
export interface $RefinementCtx<T = unknown> extends schemas.ParsePayload<T> {
|
|
@@ -288,9 +288,8 @@ export interface $ZodStringBoolParams extends TypeParams {
|
|
|
288
288
|
case?: "sensitive" | "insensitive" | undefined;
|
|
289
289
|
}
|
|
290
290
|
export declare function _stringbool(Classes: {
|
|
291
|
-
|
|
291
|
+
Codec?: typeof schemas.$ZodCodec;
|
|
292
292
|
Boolean?: typeof schemas.$ZodBoolean;
|
|
293
|
-
Transform?: typeof schemas.$ZodTransform;
|
|
294
293
|
String?: typeof schemas.$ZodString;
|
|
295
|
-
}, _params?: string | $ZodStringBoolParams): schemas.$
|
|
294
|
+
}, _params?: string | $ZodStringBoolParams): schemas.$ZodCodec<schemas.$ZodString, schemas.$ZodBoolean>;
|
|
296
295
|
export declare function _stringFormat<Format extends string>(Class: typeof schemas.$ZodCustomStringFormat, format: Format, fnOrRegex: ((arg: string) => util.MaybeAsync<unknown>) | RegExp, _params?: string | $ZodStringFormatParams): schemas.$ZodCustomStringFormat<Format>;
|