zod-to-mini
v0.0.1
Published
A CLI tool to convert Zod schemas to @zod/mini schemas.
Downloads
11
Readme
Zod to mini
What
Zod v4 introduces a new minimalist API through @zod/mini that follows a more functional approach. This tool helps you migrate your existing Zod v3 codebase to the new format with minimal effort.
Running the migration tool
npx zod-to-mini-converterUsage
Run the command in the root of your project to migrate all your files to the new format.
By default, the tool uses your project's tsconfig.json for configuration. You can specify a different tsconfig path if needed:
npx zod-to-mini path/to/custom/tsconfig.jsonWhat does it migrate?
- Imports: Replaces imports from
zodwith@zod/mini - Validation methods: Replaces method chaining with the new functional
checkpipe syntax - Deprecated methods: Updates deprecated methods with their newer equivalents
- Method mappings: Transforms method names according to the new API
Examples
Before:
import * as z from 'zod';
const userSchema = z.object({
username: z.string().min(3).max(20),
email: z.string().email(),
age: z.number().min(18).optional(),
});After:
import * as z from '@zod/mini';
const userSchema = z.object({
username: z.string().check(z.minLength(3), z.maxLength(20)),
email: z.string().check(z.email()),
age: z.optional(z.number().check(z.gte(18))),
});What's not included in @zod/mini
If you use any of the following methods in your Zod schemas, then these methods will not be migrated.
After the migration there will be compilation errors that need manual adjustments.
If you need these methods, you can use the zod package.
transformcoercedefault
Contributing
Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.
Found an issue? Please open an issue.
