formik icon indicating copy to clipboard operation
formik copied to clipboard

Feature: Pass Yup context to validationSchema using new prop validationSchemaContext in <Formik>

Open john-raymon opened this issue 2 years ago • 10 comments

Closes #3450

  • This PR creates a new prop in the <Formik> component called validationSchemaContext for 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.tsx and in yupHelpers.test.ts.

  • Added types for the new prop.

  • Updated the docs to include the new prop in the <Formik> api page

john-raymon avatar Aug 01 '23 05:08 john-raymon

⚠️ 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

changeset-bot[bot] avatar Aug 01 '23 05:08 changeset-bot[bot]

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

vercel[bot] avatar Aug 01 '23 05:08 vercel[bot]

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

codesandbox-ci[bot] avatar Aug 01 '23 05:08 codesandbox-ci[bot]

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 :(

mikegreiling avatar Mar 19 '24 21:03 mikegreiling

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!

Cbridger-mywellabee avatar Jun 25 '24 12:06 Cbridger-mywellabee

+1, would appreciate this PR's prioritization.

yogiduzit avatar Jul 10 '24 00:07 yogiduzit