Skip to content

Conversation

SeokminHong
Copy link
Contributor

Resolves #39

Support for the TransformedValues type was raised in issue #34. The example in that issue showed that when using Zod together with @hookform/resolvers/zod, there is no type support when the input and output differ.

This was addressed in commit fc6c0a4 by passing TransformedValues to the generic of useLens instead of the control’s FieldValues. However, a lens only deals with the input side of the form and does not concern itself with the submission type after resolution, so this change is inappropriate.

Suppose we have a Zod schema like the following.

const FormSchema = z.object({
  a: z.string().transform(value => Number.parseInt(value, 10)),
});
type FormInput = z.input<typeof FormSchema>;
type FormOutput = z.output<typeof FormSchema>; // Same as z.infer

// input: FormInput, output: FormOutput
const formMethods = useForm({ resolver: zodResolver(FormSchema) });

In this case, the form’s input type is FormInput, and the submitted data type should be FormOutput.

@aspirisen aspirisen added publish-next Publish next package version and removed publish-next Publish next package version labels Sep 30, 2025
@aspirisen aspirisen merged commit 6edb29d into react-hook-form:main Sep 30, 2025
7 of 9 checks passed
@aspirisen
Copy link
Collaborator

@SeokminHong thank you for the fix

Copy link

🎉 This PR is included in version 0.8.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

About transformed values support
2 participants