Skip to content

Commit 0c9db8f

Browse files
feat: upgrade zod to v4 (ENG-697) (#589)
1 parent fa4381d commit 0c9db8f

3 files changed

Lines changed: 11 additions & 13 deletions

File tree

packages/common/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@
7272
"devDependencies": {
7373
"@types/lodash": "4.14.178",
7474
"@types/number-to-words": "1.2.0",
75-
"zod": "3.24.1"
75+
"zod": "4.1.12"
7676
},
7777
"peerDependencies": {
78-
"zod": "^3"
78+
"zod": "^4"
7979
},
8080
"peerDependenciesMeta": {
8181
"zod": {

packages/common/src/dtos/json.dto.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* https://github.com/BenLorantfy/nestjs-zod/blob/main/packages/z/src/z/generic-types/json.ts
44
*/
55

6-
import type { ZodSchema } from 'zod';
6+
import type { ZodType } from 'zod';
77
import { z } from 'zod';
88

99
type Literal = boolean | number | string;
@@ -14,10 +14,8 @@ const literal = z.union([z.string(), z.number(), z.boolean()]);
1414
const DEFAULT_MESSAGE = 'Expected value to be a JSON-serializable';
1515

1616
export const zJSON = (message: string = DEFAULT_MESSAGE) => {
17-
const schema: ZodSchema<JSON> = z.lazy(() =>
18-
z.union([literal, z.array(schema), z.record(schema)], {
19-
invalid_type_error: message,
20-
})
17+
const schema: ZodType<JSON> = z.lazy(() =>
18+
z.union([literal, z.array(schema), z.record(z.string(), schema)], { error: message })
2119
);
2220

2321
return schema;

yarn.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,9 +1253,9 @@ __metadata:
12531253
number-to-words: 1.2.4
12541254
shallowequal: 1.1.0
12551255
typescript-fsa: 3.0.0
1256-
zod: 3.24.1
1256+
zod: 4.1.12
12571257
peerDependencies:
1258-
zod: ^3
1258+
zod: ^4
12591259
peerDependenciesMeta:
12601260
zod:
12611261
optional: true
@@ -7955,9 +7955,9 @@ __metadata:
79557955
languageName: node
79567956
linkType: hard
79577957

7958-
"zod@npm:3.24.1":
7959-
version: 3.24.1
7960-
resolution: "zod@npm:3.24.1"
7961-
checksum: dcd5334725b29555593c186fd6505878bb7ccb4f5954f728d2de24bf71f9397492d83bdb69d5b8a376eb500a02273ae0691b57deb1eb8718df3f64c77cc5534a
7958+
"zod@npm:4.1.12":
7959+
version: 4.1.12
7960+
resolution: "zod@npm:4.1.12"
7961+
checksum: 91174acc7d2ca5572ad522643474ddd60640cf6877b5d76e5d583eb25e3c4072c6f5eb92ab94f231ec5ce61c6acdfc3e0166de45fb1005b1ea54986b026b765f
79627962
languageName: node
79637963
linkType: hard

0 commit comments

Comments
 (0)