-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
validateField does not validate nested field #3252
Comments
Made a PR. Hopefully everything's correct, this is my first PR to Formik |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 60 days |
I don't want this to close, this one is important |
I have the same issue at the moment. I am trying to use |
@silberistgold Havent tried that with arrays but if |
+1 |
2 similar comments
+1 |
+1 |
Would love to see this merged |
+1 |
need this!!! how its going? |
I also just get this problem in |
actually the only workaround that i found is validate the entire form instead of each field. its not very UX friendly anyways. |
any ideas why this is not merged? This is really needed in an already painful workaround for formik not allowing validations of single field on blur, only the entire form. Now looks like we're having to do a workaround on a workaround, and it could be easily avoided with this one liner :( |
Note: it appears this bug was fixed as of release 2.2.10, via #3783 |
Bug report
Current Behavior
As stated in the title,
validateField
does not validate nested fields likeuser.name
.Expected behavior
It should set the correct error.
Reproducible example
You can switch between the commented lines. This shows the difference between usage of
validateField
with a not nested field and a nested one.https://codesandbox.io/s/naughty-frost-013fk?file=/src/App.js
Suggested solution(s)
It took me soooo many hours when I encountered it till I realized that the bug might actually be in the Formik itself. I found that when the field error is set, it should use
getIn(error, name)
instead oferror[name]
. I'm gonna create a PR with a fix and a test.Your environment
The text was updated successfully, but these errors were encountered: