Skip to content

Commit 6248795

Browse files
committed
Changelog: add migration sample, explaining breaking change.
1 parent 04c9b6c commit 6248795

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@
66

77
- Switched to Zod 4:
88
- Minimum supported version of `zod` is 3.25.0, BUT imports MUST be from `zod/v4`;
9-
- Find out why it's so weird here: https://github.com/colinhacks/zod/issues/4371
9+
- Explanation of the versioning strategy: https://github.com/colinhacks/zod/issues/4371;
10+
- Express Zod API, however, is not aiming to support both Zod 3 and Zod 4 simultaneously due to:
11+
- incompatibility of data structures;
12+
- operating composite schemas (need to avoid mixing schemas of different versions);
13+
- the temporary nature of this transition;
14+
- the advantages of Zod 4 that provide opportunities to simplifications and corrections of known issues.
1015
- `IOSchema` type had to be simplified down to a schema resulting to an `object`, but not an `array`;
1116
- Despite supporting examples by the new Zod method `.meta()`, users should still use `.example()` to set them;
1217
- Refer to [Migration guide on Zod 4](https://v4.zod.dev/v4/changelog) for adjusting your schemas;
@@ -23,6 +28,23 @@
2328
- `z.any()` and `z.unknown()` are not optional, details: https://v4.zod.dev/v4/changelog#changes-zunknown-optionality.
2429
- Changes to the plugin:
2530
- Brand is the only kind of metadata that withstands refinements and checks.
31+
- Consider the automated migration using the built-in ESLint rule.
32+
33+
```js
34+
// eslint.config.mjs — minimal ESLint 9 config to apply migrations automatically using "eslint --fix"
35+
import parser from "@typescript-eslint/parser";
36+
import migration from "express-zod-api/migration";
37+
38+
export default [
39+
{ languageOptions: { parser }, plugins: { migration } },
40+
{ files: ["**/*.ts"], rules: { "migration/v24": "error" } },
41+
];
42+
```
43+
44+
```diff
45+
- import { z } from "zod";
46+
+ import { z } from "zod/v4";
47+
```
2648

2749
## Version 23
2850

0 commit comments

Comments
 (0)