Skip to content

Commit 82d678d

Browse files
committed
add zod4 as a candidate
1 parent 366ccb7 commit 82d678d

13 files changed

Lines changed: 517 additions & 13 deletions

File tree

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,15 @@ At [Softnetics Team](https://www.softnetics.tech/), we specialize in building so
3939

4040
## Library Version
4141

42-
| Library | Version |
43-
| ----------------------------------------------------- | ------------- |
44-
| [Zod](https://zod.dev/) | 3.24.1 |
45-
| [typebox](https://github.com/sinclairzx81/typebox) | 0.34.14 |
46-
| [arktype](https://arktype.io/) | 2.0.3 |
47-
| [valibot](https://valibot.dev/) | 1.0.0-beta.14 |
48-
| [yup](https://github.com/jquense/yup) | 1.6.1 |
49-
| [@effect/schema](https://github.com/Effect-TS/effect) | 0.75.5 |
42+
| Library | Version |
43+
| ----------------------------------------------------- | -------------------------- |
44+
| [Zod](https://zod.dev/) | 3.24.1 |
45+
| [Zod4](https://zod.dev/) | 4.0.0-beta.20250414T061543 |
46+
| [typebox](https://github.com/sinclairzx81/typebox) | 0.34.14 |
47+
| [arktype](https://arktype.io/) | 2.0.3 |
48+
| [valibot](https://valibot.dev/) | 1.0.0-beta.14 |
49+
| [yup](https://github.com/jquense/yup) | 1.6.1 |
50+
| [@effect/schema](https://github.com/Effect-TS/effect) | 0.75.5 |
5051

5152
# Test Cases Explanation
5253

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"typescript": "^5.4.5",
2525
"valibot": "1.0.0-beta.14",
2626
"yup": "^1.6.1",
27-
"zod": "^3.24.1"
27+
"zod": "^3.24.1",
28+
"zod4": "npm:zod@4.0.0-beta.20250414T061543"
2829
},
2930
"devDependencies": {
3031
"@types/node": "^20.12.12",

pnpm-lock.yaml

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/__generated__/complex.zod4.ts

Lines changed: 96 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/__generated__/extend.zod4.ts

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/__generated__/simple.zod4.ts

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/__generated__/union.zod4.ts

Lines changed: 61 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/custom/transform-simple.valibot.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as v from 'valibot'
22

3-
type TransformSimple_ModelInput = v.InferInput<typeof TransformSimple_Model>
4-
type TransformSimple_ModelOutput = v.InferOutput<typeof TransformSimple_Model>
3+
export type TransformSimple_ModelInput = v.InferInput<typeof TransformSimple_Model>
4+
export type TransformSimple_ModelOutput = v.InferOutput<typeof TransformSimple_Model>
55
export const TransformSimple_Model = v.pipe(
66
v.object({
77
a: v.number(),

samples/custom/transform-simple.zod.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as z from 'zod'
22

3-
type TransformSimple_ModelInput = z.input<typeof TransformSimple_Model>
4-
type TransformSimple_ModelOutput = z.output<typeof TransformSimple_Model>
3+
export type TransformSimple_ModelInput = z.input<typeof TransformSimple_Model>
4+
export type TransformSimple_ModelOutput = z.output<typeof TransformSimple_Model>
55
export const TransformSimple_Model = z
66
.object({
77
a: z.number(),
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import * as z from 'zod4'
2+
3+
export type TransformSimple_ModelInput = z.input<typeof TransformSimple_Model>
4+
export type TransformSimple_ModelOutput = z.output<typeof TransformSimple_Model>
5+
export const TransformSimple_Model = z
6+
.object({
7+
a: z.number(),
8+
b: z.string(),
9+
c: z.boolean(),
10+
d: z.array(
11+
z.object({
12+
a: z.date(),
13+
b: z.string(),
14+
})
15+
),
16+
})
17+
.transform((input) => {
18+
return {
19+
x: `${input.a}`,
20+
y: `${input.b}`,
21+
z: `${input.c}`,
22+
l: input.d.map((item) => {
23+
return {
24+
a: item.a.toISOString(),
25+
b: item.b,
26+
}
27+
}),
28+
}
29+
})

0 commit comments

Comments
 (0)