Skip to content

Zod 4 support #768

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

Open
channyeintun opened this issue Apr 13, 2025 · 4 comments
Open

Zod 4 support #768

channyeintun opened this issue Apr 13, 2025 · 4 comments

Comments

@channyeintun
Copy link

Need support for Zod 4 and @zod/mini
Zod 4 beta and @zod/mini beta are out recently. Currently, resolver doesn't work with Zod 4 and @zod/mini.

@semet
Copy link

semet commented Apr 16, 2025

I have added related discussion in React Hook Form Repo. Looking forward for the recent update to this...

@wenerme
Copy link

wenerme commented Apr 18, 2025

xref colinhacks/zod#4074

@ukuq
Copy link

ukuq commented Apr 18, 2025

I found a solution and intend to submit a PR, but I noticed the version number on GitHub is much lower than the one on npm. Not sure why - maybe the author hasn't open-sourced the latest code? Who knows.
Below is my solution:

Object.defineProperty(ZodError.prototype, "errors", {
    get() {
        return this.issues;
    },
    enumerable: true,
    configurable: true,
});

const form = useForm<{ [x: string]: never }>({
    resolver: zodResolver(FormSchema),
    defaultValues: data as { [x: string]: never },
});

@ukuq
Copy link

ukuq commented Apr 21, 2025

I found a solution and intend to submit a PR, but I noticed the version number on GitHub is much lower than the one on npm. Not sure why - maybe the author hasn't open-sourced the latest code? Who knows. Below is my solution:

Object.defineProperty(ZodError.prototype, "errors", {
    get() {
        return this.issues;
    },
    enumerable: true,
    configurable: true,
});

const form = useForm<{ [x: string]: never }>({
    resolver: zodResolver(FormSchema),
    defaultValues: data as { [x: string]: never },
});

It seems this is controversial, so I'll close the PR for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants