|
6 | 6 |
|
7 | 7 | - Switched to Zod 4: |
8 | 8 | - 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. |
10 | 15 | - `IOSchema` type had to be simplified down to a schema resulting to an `object`, but not an `array`; |
11 | 16 | - Despite supporting examples by the new Zod method `.meta()`, users should still use `.example()` to set them; |
12 | 17 | - Refer to [Migration guide on Zod 4](https://v4.zod.dev/v4/changelog) for adjusting your schemas; |
|
23 | 28 | - `z.any()` and `z.unknown()` are not optional, details: https://v4.zod.dev/v4/changelog#changes-zunknown-optionality. |
24 | 29 | - Changes to the plugin: |
25 | 30 | - 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 | +``` |
26 | 48 |
|
27 | 49 | ## Version 23 |
28 | 50 |
|
|
0 commit comments