Skip to content

README: Add guidance on passing context to yupResolver (useForm context)#835

Merged
bluebill1049 merged 3 commits into
react-hook-form:masterfrom
eotkd4791:docs/clarify-yup-resolver-context
May 21, 2026
Merged

README: Add guidance on passing context to yupResolver (useForm context)#835
bluebill1049 merged 3 commits into
react-hook-form:masterfrom
eotkd4791:docs/clarify-yup-resolver-context

Conversation

@eotkd4791

@eotkd4791 eotkd4791 commented Jan 25, 2026

Copy link
Copy Markdown
Contributor

Reason for change

Yup typically uses the schema.validate(values, { context }) pattern, which naturally leads users to try yupResolver(schema, { context }). However, yupResolver in @hookform/resolvers does not recommend using schemaOptions.context and overrides it with the form context provided by useForm({ context }) (there is a dev warning in the code), and this is not clearly documented in the README. This can increase debugging cost for users.

What’s changed

  • Added a short explanation in the Yup section of the README on how to pass context.
  • Clarified that context should be provided via useForm({ context }), and that this value is injected into Yup’s validation context at resolver execution time, with an example.
  • Briefly clarified that schemaOptions.context is overridden by the form context, so context should be passed via useForm({ context }) instead.

Scope of impact

  • Documentation-only change (no behavior changes).

References

@eotkd4791 eotkd4791 force-pushed the docs/clarify-yup-resolver-context branch from c5f8d15 to 25adc7c Compare January 25, 2026 15:05
@eotkd4791 eotkd4791 force-pushed the docs/clarify-yup-resolver-context branch from 73e07e9 to 402df6f Compare March 28, 2026 15:56
@bluebill1049 bluebill1049 merged commit 3d29924 into react-hook-form:master May 21, 2026
1 of 2 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 5.4.0 🎉

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.

Document yupResolver context handling in react-hook-form/resolvers

2 participants