zod 4.3.0-canary.20251223T023855 → 4.3.0-canary.20251223T032816
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
CHANGED
|
@@ -2,9 +2,9 @@ import { expect, test } from "vitest";
|
|
|
2
2
|
|
|
3
3
|
import * as z from "zod/v4";
|
|
4
4
|
|
|
5
|
-
const beforeBenchmarkDate = new Date(2022, 10, 4);
|
|
6
|
-
const benchmarkDate = new Date(2022, 10, 5);
|
|
7
|
-
const afterBenchmarkDate = new Date(2022, 10, 6);
|
|
5
|
+
const beforeBenchmarkDate = new Date(Date.UTC(2022, 10, 4));
|
|
6
|
+
const benchmarkDate = new Date(Date.UTC(2022, 10, 5));
|
|
7
|
+
const afterBenchmarkDate = new Date(Date.UTC(2022, 10, 6));
|
|
8
8
|
|
|
9
9
|
const minCheck = z.date().min(benchmarkDate);
|
|
10
10
|
const maxCheck = z.date().max(benchmarkDate);
|
|
@@ -17,9 +17,40 @@ test("passing validations", () => {
|
|
|
17
17
|
maxCheck.parse(beforeBenchmarkDate);
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
-
test("
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
test("date min", () => {
|
|
21
|
+
const result = minCheck.safeParse(beforeBenchmarkDate);
|
|
22
|
+
|
|
23
|
+
expect(result.success).toEqual(false);
|
|
24
|
+
expect(result.error!.issues).toMatchInlineSnapshot(`
|
|
25
|
+
[
|
|
26
|
+
{
|
|
27
|
+
"code": "too_small",
|
|
28
|
+
"inclusive": true,
|
|
29
|
+
"message": "Too small: expected date to be >=1667606400000",
|
|
30
|
+
"minimum": 1667606400000,
|
|
31
|
+
"origin": "date",
|
|
32
|
+
"path": [],
|
|
33
|
+
},
|
|
34
|
+
]
|
|
35
|
+
`);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test("date max", () => {
|
|
39
|
+
const result = maxCheck.safeParse(afterBenchmarkDate);
|
|
40
|
+
|
|
41
|
+
expect(result.success).toEqual(false);
|
|
42
|
+
expect(result.error!.issues).toMatchInlineSnapshot(`
|
|
43
|
+
[
|
|
44
|
+
{
|
|
45
|
+
"code": "too_big",
|
|
46
|
+
"inclusive": true,
|
|
47
|
+
"maximum": 1667606400000,
|
|
48
|
+
"message": "Too big: expected date to be <=1667606400000",
|
|
49
|
+
"origin": "date",
|
|
50
|
+
"path": [],
|
|
51
|
+
},
|
|
52
|
+
]
|
|
53
|
+
`);
|
|
23
54
|
});
|
|
24
55
|
|
|
25
56
|
test("min max getters", () => {
|
package/src/v4/core/checks.ts
CHANGED
|
@@ -84,7 +84,7 @@ export const $ZodCheckLessThan: core.$constructor<$ZodCheckLessThan> = /*@__PURE
|
|
|
84
84
|
payload.issues.push({
|
|
85
85
|
origin,
|
|
86
86
|
code: "too_big",
|
|
87
|
-
maximum: def.value
|
|
87
|
+
maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
|
|
88
88
|
input: payload.value,
|
|
89
89
|
inclusive: def.inclusive,
|
|
90
90
|
inst,
|
|
@@ -135,7 +135,7 @@ export const $ZodCheckGreaterThan: core.$constructor<$ZodCheckGreaterThan> = /*@
|
|
|
135
135
|
payload.issues.push({
|
|
136
136
|
origin,
|
|
137
137
|
code: "too_small",
|
|
138
|
-
minimum: def.value
|
|
138
|
+
minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
|
|
139
139
|
input: payload.value,
|
|
140
140
|
inclusive: def.inclusive,
|
|
141
141
|
inst,
|
package/v4/core/checks.cjs
CHANGED
|
@@ -59,7 +59,7 @@ exports.$ZodCheckLessThan = core.$constructor("$ZodCheckLessThan", (inst, def) =
|
|
|
59
59
|
payload.issues.push({
|
|
60
60
|
origin,
|
|
61
61
|
code: "too_big",
|
|
62
|
-
maximum: def.value,
|
|
62
|
+
maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
|
|
63
63
|
input: payload.value,
|
|
64
64
|
inclusive: def.inclusive,
|
|
65
65
|
inst,
|
|
@@ -87,7 +87,7 @@ exports.$ZodCheckGreaterThan = core.$constructor("$ZodCheckGreaterThan", (inst,
|
|
|
87
87
|
payload.issues.push({
|
|
88
88
|
origin,
|
|
89
89
|
code: "too_small",
|
|
90
|
-
minimum: def.value,
|
|
90
|
+
minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
|
|
91
91
|
input: payload.value,
|
|
92
92
|
inclusive: def.inclusive,
|
|
93
93
|
inst,
|
package/v4/core/checks.js
CHANGED
|
@@ -33,7 +33,7 @@ export const $ZodCheckLessThan = /*@__PURE__*/ core.$constructor("$ZodCheckLessT
|
|
|
33
33
|
payload.issues.push({
|
|
34
34
|
origin,
|
|
35
35
|
code: "too_big",
|
|
36
|
-
maximum: def.value,
|
|
36
|
+
maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
|
|
37
37
|
input: payload.value,
|
|
38
38
|
inclusive: def.inclusive,
|
|
39
39
|
inst,
|
|
@@ -61,7 +61,7 @@ export const $ZodCheckGreaterThan = /*@__PURE__*/ core.$constructor("$ZodCheckGr
|
|
|
61
61
|
payload.issues.push({
|
|
62
62
|
origin,
|
|
63
63
|
code: "too_small",
|
|
64
|
-
minimum: def.value,
|
|
64
|
+
minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
|
|
65
65
|
input: payload.value,
|
|
66
66
|
inclusive: def.inclusive,
|
|
67
67
|
inst,
|