-
-
Notifications
You must be signed in to change notification settings - Fork 192
feat: support Zod 4 #777
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support Zod 4 #777
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the black TypeScript magic 🧙♂️ Really appreciate you jumping in and helping out with this. Everything looks solid and comes with a good DX too 🙌
🎉 This PR is included in version 5.1.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Amazing! |
Hello, I'm trying to use react-hook-form with zod/v4. //"react-hook-form": "^7.57.0",
import { useForm } from "react-hook-form";
//"@hookform/resolvers": "^5.1.0",
import { zodResolver } from "@hookform/resolvers/zod";
//"zod": "^3.25.57",
import { z } from "zod/v4";
const loginSchema = z.object({
email: z.email("email.invalid"),
password: z
.string()
.nonempty("password.required")
.min(8, "password.minLength"),
});
export const Component = (): void => {
useForm({
resolver: zodResolver(loginSchema),
mode: "onChange",
defaultValues: {
email: "",
password: "",
},
});
}; Does anyone have any idea of why this happens? |
Per some discussions I've been having with @bluebill1049, this PR adds support for Zod 4.
The other PR by @alexcraviotto (#776) is really solid but we decided to go another direction.
3.25.0
zodResolver
(via Zod's subpath versioning scheme)zodResolver
). There were zero breaking changes between Zod 3.24 and Zod 3.25 so there's no reason not to upgrade.Both Zod 3 and Zod 4 schemas can be passed into
zodResolver()
: