Feature: Pass Yup context to validationSchema using new prop validationSchemaContext in <Formik>
Closes #3450
- This PR creates a new prop in the
<Formik>component calledvalidationSchemaContextfor Yup context, which is then passed to the validationSchema here (see below):
https://github.com/jaredpalmer/formik/blob/ccdcb3979a0ca7de99e017a544fcaee3ef7e5936/packages/formik/src/Formik.tsx#L230-L241
Note the validateYupSchema function already had an optional context argument, and it also already had a third argument called sync which is set to default to false in the function definition. , no changes were made below. (see below)
https://github.com/jaredpalmer/formik/blob/ccdcb3979a0ca7de99e017a544fcaee3ef7e5936/packages/formik/src/Formik.tsx#L1079-L1091
-
Wrote tests in both
Formik.test.tsxand inyupHelpers.test.ts. -
Added types for the new prop.
-
Updated the docs to include the new prop in the
<Formik>api page
⚠️ No Changeset found
Latest commit: 2ef7ef601736c9ab12ce475462ddcde2abd8ddaf
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
| Name | Status | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| formik-docs | ⬜️ Ignored (Inspect) | Visit Preview | Aug 1, 2023 5:58am |
This pull request is automatically built and testable in CodeSandbox.
To see build info of the built libraries, click here or the icon next to each commit SHA.
Latest deployment of this branch, based on commit 2ef7ef601736c9ab12ce475462ddcde2abd8ddaf:
| Sandbox | Source |
|---|---|
| Formik TypeScript Playground (forked) | Configuration |
What can be done to move this PR forward? I could really use this feature and I'd be happy to contribute, but it looks like this has gone 8 months with no feedback from code owners :(
I just ripped out RHF and replaced it with Formik because RHF doesn't support errors being raised on fields that weren't touched (although it supported contexts!), only to find out Formik doesn't currently support Yup Contexts 😅, I would love it if this PR could gain some momentum!
+1, would appreciate this PR's prioritization.