zod 4.2.0-canary.20251015T161525 → 4.2.0-canary.20251017T221623
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/schemas.ts +1 -0
- package/src/v4/classic/tests/index.test.ts +1 -1
- package/src/v4/classic/tests/promise.test.ts +1 -1
- package/src/v4/classic/tests/readonly.test.ts +1 -1
- package/src/v4/core/core.ts +22 -9
- package/src/v4/core/schemas.ts +10 -19
- package/src/v4/mini/iso.ts +4 -4
- package/src/v4/mini/tests/functions.test.ts +0 -38
- package/src/v4/mini/tests/index.test.ts +1 -1
- package/v4/core/core.cjs +20 -11
- package/v4/core/core.js +20 -11
- package/v4/core/schemas.cjs +7 -17
- package/v4/core/schemas.d.cts +1 -1
- package/v4/core/schemas.d.ts +1 -1
- package/v4/core/schemas.js +7 -17
- package/v4/mini/iso.cjs +4 -4
- package/v4/mini/iso.js +4 -4
package/package.json
CHANGED
|
@@ -792,6 +792,7 @@ export interface ZodNumber extends _ZodNumber<core.$ZodNumberInternals<number>>
|
|
|
792
792
|
|
|
793
793
|
export const ZodNumber: core.$constructor<ZodNumber> = /*@__PURE__*/ core.$constructor("ZodNumber", (inst, def) => {
|
|
794
794
|
core.$ZodNumber.init(inst, def);
|
|
795
|
+
|
|
795
796
|
ZodType.init(inst, def);
|
|
796
797
|
|
|
797
798
|
inst.gt = (value, params) => inst.check(checks.gt(value, params));
|
|
@@ -749,7 +749,7 @@ test("z.json", () => {
|
|
|
749
749
|
test("z.promise", async () => {
|
|
750
750
|
const a = z.promise(z.string());
|
|
751
751
|
type a = z.output<typeof a>;
|
|
752
|
-
expectTypeOf<a>().toEqualTypeOf<string
|
|
752
|
+
expectTypeOf<a>().toEqualTypeOf<Promise<string>>();
|
|
753
753
|
|
|
754
754
|
expect(await z.safeParseAsync(a, Promise.resolve("hello"))).toMatchObject({
|
|
755
755
|
success: true,
|
|
@@ -10,7 +10,7 @@ const promSchema = z.promise(
|
|
|
10
10
|
|
|
11
11
|
test("promise inference", () => {
|
|
12
12
|
type promSchemaType = z.infer<typeof promSchema>;
|
|
13
|
-
expectTypeOf<promSchemaType>().toEqualTypeOf<{ name: string; age: number }
|
|
13
|
+
expectTypeOf<promSchemaType>().toEqualTypeOf<Promise<{ name: string; age: number }>>();
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
test("promise parsing success", async () => {
|
|
@@ -47,7 +47,7 @@ test("flat inference", () => {
|
|
|
47
47
|
expectTypeOf<typeof readonlyNumberRecord._output>().toEqualTypeOf<Readonly<Record<string, number>>>();
|
|
48
48
|
expectTypeOf<typeof readonlyObject._output>().toEqualTypeOf<{ readonly a: string; readonly 1: number }>();
|
|
49
49
|
expectTypeOf<typeof readonlyEnum._output>().toEqualTypeOf<Readonly<testEnum>>();
|
|
50
|
-
expectTypeOf<typeof readonlyPromise._output>().toEqualTypeOf<string
|
|
50
|
+
expectTypeOf<typeof readonlyPromise._output>().toEqualTypeOf<Promise<string>>();
|
|
51
51
|
});
|
|
52
52
|
|
|
53
53
|
// test("deep inference", () => {
|
package/src/v4/core/core.ts
CHANGED
|
@@ -20,21 +20,34 @@ export /*@__NO_SIDE_EFFECTS__*/ function $constructor<T extends ZodTrait, D = T[
|
|
|
20
20
|
params?: { Parent?: typeof Class }
|
|
21
21
|
): $constructor<T, D> {
|
|
22
22
|
function init(inst: T, def: D) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
if (!inst._zod) {
|
|
24
|
+
Object.defineProperty(inst, "_zod", {
|
|
25
|
+
value: {
|
|
26
|
+
def,
|
|
27
|
+
constr: _,
|
|
28
|
+
traits: new Set(),
|
|
29
|
+
},
|
|
30
|
+
enumerable: false,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
27
33
|
|
|
28
|
-
inst._zod.traits
|
|
34
|
+
if (inst._zod.traits.has(name)) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
29
37
|
|
|
30
38
|
inst._zod.traits.add(name);
|
|
39
|
+
|
|
31
40
|
initializer(inst, def);
|
|
41
|
+
|
|
32
42
|
// support prototype modifications
|
|
33
|
-
|
|
34
|
-
|
|
43
|
+
const proto = _.prototype;
|
|
44
|
+
const keys = Object.keys(proto);
|
|
45
|
+
for (let i = 0; i < keys.length; i++) {
|
|
46
|
+
const k = keys[i]!;
|
|
47
|
+
if (!(k in inst)) {
|
|
48
|
+
(inst as any)[k] = proto[k].bind(inst);
|
|
49
|
+
}
|
|
35
50
|
}
|
|
36
|
-
inst._zod.constr = _;
|
|
37
|
-
inst._zod.def = def;
|
|
38
51
|
}
|
|
39
52
|
|
|
40
53
|
// doesn't work if Parent has a constructor with arguments
|
package/src/v4/core/schemas.ts
CHANGED
|
@@ -741,10 +741,8 @@ export interface $ZodIPv4 extends $ZodType {
|
|
|
741
741
|
export const $ZodIPv4: core.$constructor<$ZodIPv4> = /*@__PURE__*/ core.$constructor("$ZodIPv4", (inst, def): void => {
|
|
742
742
|
def.pattern ??= regexes.ipv4;
|
|
743
743
|
$ZodStringFormat.init(inst, def);
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
bag.format = `ipv4`;
|
|
747
|
-
});
|
|
744
|
+
|
|
745
|
+
inst._zod.bag.format = `ipv4`;
|
|
748
746
|
});
|
|
749
747
|
|
|
750
748
|
////////////////////////////// ZodIPv6 //////////////////////////////
|
|
@@ -765,10 +763,7 @@ export const $ZodIPv6: core.$constructor<$ZodIPv6> = /*@__PURE__*/ core.$constru
|
|
|
765
763
|
def.pattern ??= regexes.ipv6;
|
|
766
764
|
$ZodStringFormat.init(inst, def);
|
|
767
765
|
|
|
768
|
-
inst._zod.
|
|
769
|
-
const bag = inst._zod.bag as $ZodStringInternals<unknown>["bag"];
|
|
770
|
-
bag.format = `ipv6`;
|
|
771
|
-
});
|
|
766
|
+
inst._zod.bag.format = `ipv6`;
|
|
772
767
|
|
|
773
768
|
inst._zod.check = (payload) => {
|
|
774
769
|
try {
|
|
@@ -879,9 +874,7 @@ export const $ZodBase64: core.$constructor<$ZodBase64> = /*@__PURE__*/ core.$con
|
|
|
879
874
|
def.pattern ??= regexes.base64;
|
|
880
875
|
$ZodStringFormat.init(inst, def);
|
|
881
876
|
|
|
882
|
-
inst._zod.
|
|
883
|
-
inst._zod.bag.contentEncoding = "base64";
|
|
884
|
-
});
|
|
877
|
+
inst._zod.bag.contentEncoding = "base64";
|
|
885
878
|
|
|
886
879
|
inst._zod.check = (payload) => {
|
|
887
880
|
if (isValidBase64(payload.value)) return;
|
|
@@ -918,9 +911,7 @@ export const $ZodBase64URL: core.$constructor<$ZodBase64URL> = /*@__PURE__*/ cor
|
|
|
918
911
|
def.pattern ??= regexes.base64url;
|
|
919
912
|
$ZodStringFormat.init(inst, def);
|
|
920
913
|
|
|
921
|
-
inst._zod.
|
|
922
|
-
inst._zod.bag.contentEncoding = "base64url";
|
|
923
|
-
});
|
|
914
|
+
inst._zod.bag.contentEncoding = "base64url";
|
|
924
915
|
|
|
925
916
|
inst._zod.check = (payload) => {
|
|
926
917
|
if (isValidBase64URL(payload.value)) return;
|
|
@@ -1065,8 +1056,8 @@ export interface $ZodNumber<Input = unknown> extends $ZodType {
|
|
|
1065
1056
|
|
|
1066
1057
|
export const $ZodNumber: core.$constructor<$ZodNumber> = /*@__PURE__*/ core.$constructor("$ZodNumber", (inst, def) => {
|
|
1067
1058
|
$ZodType.init(inst, def);
|
|
1068
|
-
inst._zod.pattern = inst._zod.bag.pattern ?? regexes.number;
|
|
1069
1059
|
|
|
1060
|
+
inst._zod.pattern = inst._zod.bag.pattern ?? regexes.number;
|
|
1070
1061
|
inst._zod.parse = (payload, _ctx) => {
|
|
1071
1062
|
if (def.coerce)
|
|
1072
1063
|
try {
|
|
@@ -1113,10 +1104,10 @@ export interface $ZodNumberFormat extends $ZodType {
|
|
|
1113
1104
|
}
|
|
1114
1105
|
|
|
1115
1106
|
export const $ZodNumberFormat: core.$constructor<$ZodNumberFormat> = /*@__PURE__*/ core.$constructor(
|
|
1116
|
-
"$
|
|
1107
|
+
"$ZodNumberFormat",
|
|
1117
1108
|
(inst, def) => {
|
|
1118
1109
|
checks.$ZodCheckNumberFormat.init(inst, def);
|
|
1119
|
-
$ZodNumber.init(inst, def); // no format
|
|
1110
|
+
$ZodNumber.init(inst, def); // no format checks
|
|
1120
1111
|
}
|
|
1121
1112
|
);
|
|
1122
1113
|
|
|
@@ -1237,7 +1228,7 @@ export interface $ZodBigIntFormat extends $ZodType {
|
|
|
1237
1228
|
}
|
|
1238
1229
|
|
|
1239
1230
|
export const $ZodBigIntFormat: core.$constructor<$ZodBigIntFormat> = /*@__PURE__*/ core.$constructor(
|
|
1240
|
-
"$
|
|
1231
|
+
"$ZodBigIntFormat",
|
|
1241
1232
|
(inst, def) => {
|
|
1242
1233
|
checks.$ZodCheckBigIntFormat.init(inst, def);
|
|
1243
1234
|
$ZodBigInt.init(inst, def); // no format checks
|
|
@@ -4112,7 +4103,7 @@ export interface $ZodPromiseDef<T extends SomeType = $ZodType> extends $ZodTypeD
|
|
|
4112
4103
|
}
|
|
4113
4104
|
|
|
4114
4105
|
export interface $ZodPromiseInternals<T extends SomeType = $ZodType>
|
|
4115
|
-
extends $ZodTypeInternals<core.output<T
|
|
4106
|
+
extends $ZodTypeInternals<Promise<core.output<T>>, util.MaybeAsync<core.input<T>>> {
|
|
4116
4107
|
def: $ZodPromiseDef<T>;
|
|
4117
4108
|
isst: never;
|
|
4118
4109
|
}
|
package/src/v4/mini/iso.ts
CHANGED
|
@@ -6,7 +6,7 @@ export interface ZodMiniISODateTime extends schemas.ZodMiniStringFormat<"datetim
|
|
|
6
6
|
_zod: core.$ZodISODateTimeInternals;
|
|
7
7
|
}
|
|
8
8
|
export const ZodMiniISODateTime: core.$constructor<ZodMiniISODateTime> = /*@__PURE__*/ core.$constructor(
|
|
9
|
-
"
|
|
9
|
+
"ZodMiniISODateTime",
|
|
10
10
|
(inst, def) => {
|
|
11
11
|
core.$ZodISODateTime.init(inst, def);
|
|
12
12
|
schemas.ZodMiniStringFormat.init(inst, def);
|
|
@@ -21,7 +21,7 @@ export interface ZodMiniISODate extends schemas.ZodMiniStringFormat<"date"> {
|
|
|
21
21
|
_zod: core.$ZodISODateInternals;
|
|
22
22
|
}
|
|
23
23
|
export const ZodMiniISODate: core.$constructor<ZodMiniISODate> = /*@__PURE__*/ core.$constructor(
|
|
24
|
-
"
|
|
24
|
+
"ZodMiniISODate",
|
|
25
25
|
(inst, def) => {
|
|
26
26
|
core.$ZodISODate.init(inst, def);
|
|
27
27
|
schemas.ZodMiniStringFormat.init(inst, def);
|
|
@@ -36,7 +36,7 @@ export interface ZodMiniISOTime extends schemas.ZodMiniStringFormat<"time"> {
|
|
|
36
36
|
_zod: core.$ZodISOTimeInternals;
|
|
37
37
|
}
|
|
38
38
|
export const ZodMiniISOTime: core.$constructor<ZodMiniISOTime> = /*@__PURE__*/ core.$constructor(
|
|
39
|
-
"
|
|
39
|
+
"ZodMiniISOTime",
|
|
40
40
|
(inst, def) => {
|
|
41
41
|
core.$ZodISOTime.init(inst, def);
|
|
42
42
|
schemas.ZodMiniStringFormat.init(inst, def);
|
|
@@ -51,7 +51,7 @@ export interface ZodMiniISODuration extends schemas.ZodMiniStringFormat<"duratio
|
|
|
51
51
|
_zod: core.$ZodISODurationInternals;
|
|
52
52
|
}
|
|
53
53
|
export const ZodMiniISODuration: core.$constructor<ZodMiniISODuration> = /*@__PURE__*/ core.$constructor(
|
|
54
|
-
"
|
|
54
|
+
"ZodMiniISODuration",
|
|
55
55
|
(inst, def) => {
|
|
56
56
|
core.$ZodISODuration.init(inst, def);
|
|
57
57
|
schemas.ZodMiniStringFormat.init(inst, def);
|
|
@@ -1,43 +1,5 @@
|
|
|
1
1
|
import { expect, test } from "vitest";
|
|
2
|
-
// import * as z from "zod/v4/core";
|
|
3
2
|
|
|
4
3
|
test("z.function", () => {
|
|
5
4
|
expect(true).toEqual(true);
|
|
6
5
|
});
|
|
7
|
-
|
|
8
|
-
// test("z.function", () => {
|
|
9
|
-
// const a = z.function({
|
|
10
|
-
// args: z.tuple([z.string()]),
|
|
11
|
-
// returns: z.string(),
|
|
12
|
-
// });
|
|
13
|
-
|
|
14
|
-
// const myFunc = a.implement((name: string | number) => `Hello, ${name}!`);
|
|
15
|
-
|
|
16
|
-
// expect(myFunc("world")).toEqual("Hello, world!");
|
|
17
|
-
// expect(() => myFunc(123 as any)).toThrow();
|
|
18
|
-
|
|
19
|
-
// // this won't run
|
|
20
|
-
// () => {
|
|
21
|
-
// // @ts-expect-error
|
|
22
|
-
// const r = myFunc(123);
|
|
23
|
-
// expectTypeOf(r).toEqualTypeOf<string>();
|
|
24
|
-
// };
|
|
25
|
-
// });
|
|
26
|
-
|
|
27
|
-
// test("z.function async", async () => {
|
|
28
|
-
// const b = z.function({
|
|
29
|
-
// args: z.tuple([z.string()]).$check(async (_) => {}),
|
|
30
|
-
// returns: z.string().$check(async (_) => {}),
|
|
31
|
-
// });
|
|
32
|
-
// const myFuncAsync = b.implementAsync(async (name) => `Hello, ${name}!`);
|
|
33
|
-
|
|
34
|
-
// expect(await myFuncAsync("world")).toEqual("Hello, world!");
|
|
35
|
-
// expect(myFuncAsync(123 as any)).rejects.toThrow();
|
|
36
|
-
|
|
37
|
-
// // this won't run
|
|
38
|
-
// () => {
|
|
39
|
-
// // @ts-expect-error
|
|
40
|
-
// const r = myFuncAsync(123);
|
|
41
|
-
// expectTypeOf(r).toEqualTypeOf<Promise<string>>();
|
|
42
|
-
// };
|
|
43
|
-
// });
|
|
@@ -789,7 +789,7 @@ test("z.stringbool", () => {
|
|
|
789
789
|
test("z.promise", async () => {
|
|
790
790
|
const a = z.promise(z.string());
|
|
791
791
|
type a = z.output<typeof a>;
|
|
792
|
-
expectTypeOf<a>().toEqualTypeOf<string
|
|
792
|
+
expectTypeOf<a>().toEqualTypeOf<Promise<string>>();
|
|
793
793
|
|
|
794
794
|
expect(await z.safeParseAsync(a, Promise.resolve("hello"))).toMatchObject({
|
|
795
795
|
success: true,
|
package/v4/core/core.cjs
CHANGED
|
@@ -9,21 +9,30 @@ exports.NEVER = Object.freeze({
|
|
|
9
9
|
});
|
|
10
10
|
function $constructor(name, initializer, params) {
|
|
11
11
|
function init(inst, def) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
if (!inst._zod) {
|
|
13
|
+
Object.defineProperty(inst, "_zod", {
|
|
14
|
+
value: {
|
|
15
|
+
def,
|
|
16
|
+
constr: _,
|
|
17
|
+
traits: new Set(),
|
|
18
|
+
},
|
|
19
|
+
enumerable: false,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
if (inst._zod.traits.has(name)) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
18
25
|
inst._zod.traits.add(name);
|
|
19
26
|
initializer(inst, def);
|
|
20
27
|
// support prototype modifications
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
28
|
+
const proto = _.prototype;
|
|
29
|
+
const keys = Object.keys(proto);
|
|
30
|
+
for (let i = 0; i < keys.length; i++) {
|
|
31
|
+
const k = keys[i];
|
|
32
|
+
if (!(k in inst)) {
|
|
33
|
+
inst[k] = proto[k].bind(inst);
|
|
34
|
+
}
|
|
24
35
|
}
|
|
25
|
-
inst._zod.constr = _;
|
|
26
|
-
inst._zod.def = def;
|
|
27
36
|
}
|
|
28
37
|
// doesn't work if Parent has a constructor with arguments
|
|
29
38
|
const Parent = params?.Parent ?? Object;
|
package/v4/core/core.js
CHANGED
|
@@ -4,21 +4,30 @@ export const NEVER = Object.freeze({
|
|
|
4
4
|
});
|
|
5
5
|
export /*@__NO_SIDE_EFFECTS__*/ function $constructor(name, initializer, params) {
|
|
6
6
|
function init(inst, def) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
if (!inst._zod) {
|
|
8
|
+
Object.defineProperty(inst, "_zod", {
|
|
9
|
+
value: {
|
|
10
|
+
def,
|
|
11
|
+
constr: _,
|
|
12
|
+
traits: new Set(),
|
|
13
|
+
},
|
|
14
|
+
enumerable: false,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
if (inst._zod.traits.has(name)) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
13
20
|
inst._zod.traits.add(name);
|
|
14
21
|
initializer(inst, def);
|
|
15
22
|
// support prototype modifications
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
23
|
+
const proto = _.prototype;
|
|
24
|
+
const keys = Object.keys(proto);
|
|
25
|
+
for (let i = 0; i < keys.length; i++) {
|
|
26
|
+
const k = keys[i];
|
|
27
|
+
if (!(k in inst)) {
|
|
28
|
+
inst[k] = proto[k].bind(inst);
|
|
29
|
+
}
|
|
19
30
|
}
|
|
20
|
-
inst._zod.constr = _;
|
|
21
|
-
inst._zod.def = def;
|
|
22
31
|
}
|
|
23
32
|
// doesn't work if Parent has a constructor with arguments
|
|
24
33
|
const Parent = params?.Parent ?? Object;
|
package/v4/core/schemas.cjs
CHANGED
|
@@ -327,18 +327,12 @@ exports.$ZodISODuration = core.$constructor("$ZodISODuration", (inst, def) => {
|
|
|
327
327
|
exports.$ZodIPv4 = core.$constructor("$ZodIPv4", (inst, def) => {
|
|
328
328
|
def.pattern ?? (def.pattern = regexes.ipv4);
|
|
329
329
|
exports.$ZodStringFormat.init(inst, def);
|
|
330
|
-
inst._zod.
|
|
331
|
-
const bag = inst._zod.bag;
|
|
332
|
-
bag.format = `ipv4`;
|
|
333
|
-
});
|
|
330
|
+
inst._zod.bag.format = `ipv4`;
|
|
334
331
|
});
|
|
335
332
|
exports.$ZodIPv6 = core.$constructor("$ZodIPv6", (inst, def) => {
|
|
336
333
|
def.pattern ?? (def.pattern = regexes.ipv6);
|
|
337
334
|
exports.$ZodStringFormat.init(inst, def);
|
|
338
|
-
inst._zod.
|
|
339
|
-
const bag = inst._zod.bag;
|
|
340
|
-
bag.format = `ipv6`;
|
|
341
|
-
});
|
|
335
|
+
inst._zod.bag.format = `ipv6`;
|
|
342
336
|
inst._zod.check = (payload) => {
|
|
343
337
|
try {
|
|
344
338
|
// @ts-ignore
|
|
@@ -408,9 +402,7 @@ function isValidBase64(data) {
|
|
|
408
402
|
exports.$ZodBase64 = core.$constructor("$ZodBase64", (inst, def) => {
|
|
409
403
|
def.pattern ?? (def.pattern = regexes.base64);
|
|
410
404
|
exports.$ZodStringFormat.init(inst, def);
|
|
411
|
-
inst._zod.
|
|
412
|
-
inst._zod.bag.contentEncoding = "base64";
|
|
413
|
-
});
|
|
405
|
+
inst._zod.bag.contentEncoding = "base64";
|
|
414
406
|
inst._zod.check = (payload) => {
|
|
415
407
|
if (isValidBase64(payload.value))
|
|
416
408
|
return;
|
|
@@ -434,9 +426,7 @@ function isValidBase64URL(data) {
|
|
|
434
426
|
exports.$ZodBase64URL = core.$constructor("$ZodBase64URL", (inst, def) => {
|
|
435
427
|
def.pattern ?? (def.pattern = regexes.base64url);
|
|
436
428
|
exports.$ZodStringFormat.init(inst, def);
|
|
437
|
-
inst._zod.
|
|
438
|
-
inst._zod.bag.contentEncoding = "base64url";
|
|
439
|
-
});
|
|
429
|
+
inst._zod.bag.contentEncoding = "base64url";
|
|
440
430
|
inst._zod.check = (payload) => {
|
|
441
431
|
if (isValidBase64URL(payload.value))
|
|
442
432
|
return;
|
|
@@ -534,9 +524,9 @@ exports.$ZodNumber = core.$constructor("$ZodNumber", (inst, def) => {
|
|
|
534
524
|
return payload;
|
|
535
525
|
};
|
|
536
526
|
});
|
|
537
|
-
exports.$ZodNumberFormat = core.$constructor("$
|
|
527
|
+
exports.$ZodNumberFormat = core.$constructor("$ZodNumberFormat", (inst, def) => {
|
|
538
528
|
checks.$ZodCheckNumberFormat.init(inst, def);
|
|
539
|
-
exports.$ZodNumber.init(inst, def); // no format
|
|
529
|
+
exports.$ZodNumber.init(inst, def); // no format checks
|
|
540
530
|
});
|
|
541
531
|
exports.$ZodBoolean = core.$constructor("$ZodBoolean", (inst, def) => {
|
|
542
532
|
exports.$ZodType.init(inst, def);
|
|
@@ -579,7 +569,7 @@ exports.$ZodBigInt = core.$constructor("$ZodBigInt", (inst, def) => {
|
|
|
579
569
|
return payload;
|
|
580
570
|
};
|
|
581
571
|
});
|
|
582
|
-
exports.$ZodBigIntFormat = core.$constructor("$
|
|
572
|
+
exports.$ZodBigIntFormat = core.$constructor("$ZodBigIntFormat", (inst, def) => {
|
|
583
573
|
checks.$ZodCheckBigIntFormat.init(inst, def);
|
|
584
574
|
exports.$ZodBigInt.init(inst, def); // no format checks
|
|
585
575
|
});
|
package/v4/core/schemas.d.cts
CHANGED
|
@@ -1063,7 +1063,7 @@ export interface $ZodPromiseDef<T extends SomeType = $ZodType> extends $ZodTypeD
|
|
|
1063
1063
|
type: "promise";
|
|
1064
1064
|
innerType: T;
|
|
1065
1065
|
}
|
|
1066
|
-
export interface $ZodPromiseInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<core.output<T
|
|
1066
|
+
export interface $ZodPromiseInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<Promise<core.output<T>>, util.MaybeAsync<core.input<T>>> {
|
|
1067
1067
|
def: $ZodPromiseDef<T>;
|
|
1068
1068
|
isst: never;
|
|
1069
1069
|
}
|
package/v4/core/schemas.d.ts
CHANGED
|
@@ -1063,7 +1063,7 @@ export interface $ZodPromiseDef<T extends SomeType = $ZodType> extends $ZodTypeD
|
|
|
1063
1063
|
type: "promise";
|
|
1064
1064
|
innerType: T;
|
|
1065
1065
|
}
|
|
1066
|
-
export interface $ZodPromiseInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<core.output<T
|
|
1066
|
+
export interface $ZodPromiseInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<Promise<core.output<T>>, util.MaybeAsync<core.input<T>>> {
|
|
1067
1067
|
def: $ZodPromiseDef<T>;
|
|
1068
1068
|
isst: never;
|
|
1069
1069
|
}
|
package/v4/core/schemas.js
CHANGED
|
@@ -296,18 +296,12 @@ export const $ZodISODuration = /*@__PURE__*/ core.$constructor("$ZodISODuration"
|
|
|
296
296
|
export const $ZodIPv4 = /*@__PURE__*/ core.$constructor("$ZodIPv4", (inst, def) => {
|
|
297
297
|
def.pattern ?? (def.pattern = regexes.ipv4);
|
|
298
298
|
$ZodStringFormat.init(inst, def);
|
|
299
|
-
inst._zod.
|
|
300
|
-
const bag = inst._zod.bag;
|
|
301
|
-
bag.format = `ipv4`;
|
|
302
|
-
});
|
|
299
|
+
inst._zod.bag.format = `ipv4`;
|
|
303
300
|
});
|
|
304
301
|
export const $ZodIPv6 = /*@__PURE__*/ core.$constructor("$ZodIPv6", (inst, def) => {
|
|
305
302
|
def.pattern ?? (def.pattern = regexes.ipv6);
|
|
306
303
|
$ZodStringFormat.init(inst, def);
|
|
307
|
-
inst._zod.
|
|
308
|
-
const bag = inst._zod.bag;
|
|
309
|
-
bag.format = `ipv6`;
|
|
310
|
-
});
|
|
304
|
+
inst._zod.bag.format = `ipv6`;
|
|
311
305
|
inst._zod.check = (payload) => {
|
|
312
306
|
try {
|
|
313
307
|
// @ts-ignore
|
|
@@ -377,9 +371,7 @@ export function isValidBase64(data) {
|
|
|
377
371
|
export const $ZodBase64 = /*@__PURE__*/ core.$constructor("$ZodBase64", (inst, def) => {
|
|
378
372
|
def.pattern ?? (def.pattern = regexes.base64);
|
|
379
373
|
$ZodStringFormat.init(inst, def);
|
|
380
|
-
inst._zod.
|
|
381
|
-
inst._zod.bag.contentEncoding = "base64";
|
|
382
|
-
});
|
|
374
|
+
inst._zod.bag.contentEncoding = "base64";
|
|
383
375
|
inst._zod.check = (payload) => {
|
|
384
376
|
if (isValidBase64(payload.value))
|
|
385
377
|
return;
|
|
@@ -403,9 +395,7 @@ export function isValidBase64URL(data) {
|
|
|
403
395
|
export const $ZodBase64URL = /*@__PURE__*/ core.$constructor("$ZodBase64URL", (inst, def) => {
|
|
404
396
|
def.pattern ?? (def.pattern = regexes.base64url);
|
|
405
397
|
$ZodStringFormat.init(inst, def);
|
|
406
|
-
inst._zod.
|
|
407
|
-
inst._zod.bag.contentEncoding = "base64url";
|
|
408
|
-
});
|
|
398
|
+
inst._zod.bag.contentEncoding = "base64url";
|
|
409
399
|
inst._zod.check = (payload) => {
|
|
410
400
|
if (isValidBase64URL(payload.value))
|
|
411
401
|
return;
|
|
@@ -503,9 +493,9 @@ export const $ZodNumber = /*@__PURE__*/ core.$constructor("$ZodNumber", (inst, d
|
|
|
503
493
|
return payload;
|
|
504
494
|
};
|
|
505
495
|
});
|
|
506
|
-
export const $ZodNumberFormat = /*@__PURE__*/ core.$constructor("$
|
|
496
|
+
export const $ZodNumberFormat = /*@__PURE__*/ core.$constructor("$ZodNumberFormat", (inst, def) => {
|
|
507
497
|
checks.$ZodCheckNumberFormat.init(inst, def);
|
|
508
|
-
$ZodNumber.init(inst, def); // no format
|
|
498
|
+
$ZodNumber.init(inst, def); // no format checks
|
|
509
499
|
});
|
|
510
500
|
export const $ZodBoolean = /*@__PURE__*/ core.$constructor("$ZodBoolean", (inst, def) => {
|
|
511
501
|
$ZodType.init(inst, def);
|
|
@@ -548,7 +538,7 @@ export const $ZodBigInt = /*@__PURE__*/ core.$constructor("$ZodBigInt", (inst, d
|
|
|
548
538
|
return payload;
|
|
549
539
|
};
|
|
550
540
|
});
|
|
551
|
-
export const $ZodBigIntFormat = /*@__PURE__*/ core.$constructor("$
|
|
541
|
+
export const $ZodBigIntFormat = /*@__PURE__*/ core.$constructor("$ZodBigIntFormat", (inst, def) => {
|
|
552
542
|
checks.$ZodCheckBigIntFormat.init(inst, def);
|
|
553
543
|
$ZodBigInt.init(inst, def); // no format checks
|
|
554
544
|
});
|
package/v4/mini/iso.cjs
CHANGED
|
@@ -30,28 +30,28 @@ exports.time = time;
|
|
|
30
30
|
exports.duration = duration;
|
|
31
31
|
const core = __importStar(require("../core/index.cjs"));
|
|
32
32
|
const schemas = __importStar(require("./schemas.cjs"));
|
|
33
|
-
exports.ZodMiniISODateTime = core.$constructor("
|
|
33
|
+
exports.ZodMiniISODateTime = core.$constructor("ZodMiniISODateTime", (inst, def) => {
|
|
34
34
|
core.$ZodISODateTime.init(inst, def);
|
|
35
35
|
schemas.ZodMiniStringFormat.init(inst, def);
|
|
36
36
|
});
|
|
37
37
|
function datetime(params) {
|
|
38
38
|
return core._isoDateTime(exports.ZodMiniISODateTime, params);
|
|
39
39
|
}
|
|
40
|
-
exports.ZodMiniISODate = core.$constructor("
|
|
40
|
+
exports.ZodMiniISODate = core.$constructor("ZodMiniISODate", (inst, def) => {
|
|
41
41
|
core.$ZodISODate.init(inst, def);
|
|
42
42
|
schemas.ZodMiniStringFormat.init(inst, def);
|
|
43
43
|
});
|
|
44
44
|
function date(params) {
|
|
45
45
|
return core._isoDate(exports.ZodMiniISODate, params);
|
|
46
46
|
}
|
|
47
|
-
exports.ZodMiniISOTime = core.$constructor("
|
|
47
|
+
exports.ZodMiniISOTime = core.$constructor("ZodMiniISOTime", (inst, def) => {
|
|
48
48
|
core.$ZodISOTime.init(inst, def);
|
|
49
49
|
schemas.ZodMiniStringFormat.init(inst, def);
|
|
50
50
|
});
|
|
51
51
|
function time(params) {
|
|
52
52
|
return core._isoTime(exports.ZodMiniISOTime, params);
|
|
53
53
|
}
|
|
54
|
-
exports.ZodMiniISODuration = core.$constructor("
|
|
54
|
+
exports.ZodMiniISODuration = core.$constructor("ZodMiniISODuration", (inst, def) => {
|
|
55
55
|
core.$ZodISODuration.init(inst, def);
|
|
56
56
|
schemas.ZodMiniStringFormat.init(inst, def);
|
|
57
57
|
});
|
package/v4/mini/iso.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import * as core from "../core/index.js";
|
|
2
2
|
import * as schemas from "./schemas.js";
|
|
3
|
-
export const ZodMiniISODateTime = /*@__PURE__*/ core.$constructor("
|
|
3
|
+
export const ZodMiniISODateTime = /*@__PURE__*/ core.$constructor("ZodMiniISODateTime", (inst, def) => {
|
|
4
4
|
core.$ZodISODateTime.init(inst, def);
|
|
5
5
|
schemas.ZodMiniStringFormat.init(inst, def);
|
|
6
6
|
});
|
|
7
7
|
export function datetime(params) {
|
|
8
8
|
return core._isoDateTime(ZodMiniISODateTime, params);
|
|
9
9
|
}
|
|
10
|
-
export const ZodMiniISODate = /*@__PURE__*/ core.$constructor("
|
|
10
|
+
export const ZodMiniISODate = /*@__PURE__*/ core.$constructor("ZodMiniISODate", (inst, def) => {
|
|
11
11
|
core.$ZodISODate.init(inst, def);
|
|
12
12
|
schemas.ZodMiniStringFormat.init(inst, def);
|
|
13
13
|
});
|
|
14
14
|
export function date(params) {
|
|
15
15
|
return core._isoDate(ZodMiniISODate, params);
|
|
16
16
|
}
|
|
17
|
-
export const ZodMiniISOTime = /*@__PURE__*/ core.$constructor("
|
|
17
|
+
export const ZodMiniISOTime = /*@__PURE__*/ core.$constructor("ZodMiniISOTime", (inst, def) => {
|
|
18
18
|
core.$ZodISOTime.init(inst, def);
|
|
19
19
|
schemas.ZodMiniStringFormat.init(inst, def);
|
|
20
20
|
});
|
|
21
21
|
export function time(params) {
|
|
22
22
|
return core._isoTime(ZodMiniISOTime, params);
|
|
23
23
|
}
|
|
24
|
-
export const ZodMiniISODuration = /*@__PURE__*/ core.$constructor("
|
|
24
|
+
export const ZodMiniISODuration = /*@__PURE__*/ core.$constructor("ZodMiniISODuration", (inst, def) => {
|
|
25
25
|
core.$ZodISODuration.init(inst, def);
|
|
26
26
|
schemas.ZodMiniStringFormat.init(inst, def);
|
|
27
27
|
});
|