Skip to content
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

Add ability to pass context for validation #2053

Open
KhodeN opened this issue Nov 21, 2019 · 4 comments
Open

Add ability to pass context for validation #2053

KhodeN opened this issue Nov 21, 2019 · 4 comments
Labels

Comments

@KhodeN
Copy link

KhodeN commented Nov 21, 2019

🚀 Feature request

Current Behavior

I can use only pure validation schemas (for validationSchema prop).

Desired Behavior

Ability to pass context argument for validateAt function inside Formik.

https://github.com/jquense/yup#mixedvalidatevalue-any-options-object-promiseany-validationerror

Suggested Solution

Add validationContext optional prop for and pass it as schema.validateAt(field, values, {context})

Or, more customizable, add validationOptions and pass it as schema.validateAt(field, values, options)

Who does this impact? Who is this for?

It may be useful for checking the entry in the list of values ​​loaded later (e.g., constants or dictionaries). In custom function in when, for example.

Or for tuning validation, see https://github.com/jquense/yup#mixedwhenkeys-string--arraystring-builder-object--value-schema-schema-schema example

Describe alternatives you've considered

custom function for validate prop, but this solution is ugly

@stale stale bot added the stale label Jan 20, 2020
@kaldebert
Copy link

👍 This is a must-have feature ! Can't wait to have this.

@stale stale bot removed the stale label Feb 18, 2020
@stale stale bot added the stale label Apr 18, 2020
@codecadwallader
Copy link

custom function for validate prop, but this solution is ugly

@KhodeN Looks like this is still an open issue.. do you recall at all what happened when trying to customize the validate prop that made it ugly? I'm probably going to head in this direction..

@codecadwallader
Copy link

Recommend looking at work-around in #506 for anyone else coming to this issue (i.e. define validate function to mimic the validationSchema behavior).

@egemon
Copy link

egemon commented Mar 3, 2021

+1 to feature

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

No branches or pull requests

4 participants