{"action":"created","issue":{"url":"https://api.github.com/repos/jaredpalmer/formik/issues/652","repository_url":"https://api.github.com/repos/jaredpalmer/formik","labels_url":"https://api.github.com/repos/jaredpalmer/formik/issues/652/labels{/name}","comments_url":"https://api.github.com/repos/jaredpalmer/formik/issues/652/comments","events_url":"https://api.github.com/repos/jaredpalmer/formik/issues/652/events","html_url":"https://github.com/jaredpalmer/formik/issues/652","id":325072733,"number":652,"title":"Conditional Validation","user":{"login":"zebulonj","id":1703671,"avatar_url":"https://avatars3.githubusercontent.com/u/1703671?v=4","gravatar_id":"","url":"https://api.github.com/users/zebulonj","html_url":"https://github.com/zebulonj","followers_url":"https://api.github.com/users/zebulonj/followers","following_url":"https://api.github.com/users/zebulonj/following{/other_user}","gists_url":"https://api.github.com/users/zebulonj/gists{/gist_id}","starred_url":"https://api.github.com/users/zebulonj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zebulonj/subscriptions","organizations_url":"https://api.github.com/users/zebulonj/orgs","repos_url":"https://api.github.com/users/zebulonj/repos","events_url":"https://api.github.com/users/zebulonj/events{/privacy}","received_events_url":"https://api.github.com/users/zebulonj/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-05-21T21:56:17Z","updated_at":"2018-05-26T11:37:54Z","closed_at":null,"author_association":"NONE","body":"**Is your feature request related to a problem? Please describe.**\r\nI've recently had need to support multiple actions on a form (specifically, \"Submit\" and \"Save draft\"), where each action had different validation requirements (you don't want to enforce required fields when saving as draft, but you may have need for validation to prevent field value lengths exceeding database limits). However, Formik doesn't even execute onSubmit unless validation passes.\r\n\r\n**Describe the solution you'd like**\r\nI'd like Formik to always execute the `onSubmit` handler when `handleSubmit()` or `submitForm()` are called... passing `errors` and `isValid` to the `onSubmit` handler and leaving it to the user what action to take. Recognizing that this would be a breaking change, I think it would be acceptable to add an option to enable this behavior (off be default).\r\n\r\n**Describe alternatives you've considered**\r\nHandling validation outside of Formik. 👎\r\n\r\n**Additional context**\r\nI've forked Formik and implemented this [here](https://github.com/zebulonj/formik/commit/82d8ce3596685077093deec3df766771fcb714f4). Related: in the linked fork I also added the [ability to pass flags](https://github.com/zebulonj/formik/commit/addfbab418ae5265db69cc96394e9c4724d24b66) to `onSubmit` via the `submitForm()` method.\r\n"},"comment":{"url":"https://api.github.com/repos/jaredpalmer/formik/issues/comments/392255719","html_url":"https://github.com/jaredpalmer/formik/issues/652#issuecomment-392255719","issue_url":"https://api.github.com/repos/jaredpalmer/formik/issues/652","id":392255719,"user":{"login":"latviancoder","id":3055171,"avatar_url":"https://avatars1.githubusercontent.com/u/3055171?v=4","gravatar_id":"","url":"https://api.github.com/users/latviancoder","html_url":"https://github.com/latviancoder","followers_url":"https://api.github.com/users/latviancoder/followers","following_url":"https://api.github.com/users/latviancoder/following{/other_user}","gists_url":"https://api.github.com/users/latviancoder/gists{/gist_id}","starred_url":"https://api.github.com/users/latviancoder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/latviancoder/subscriptions","organizations_url":"https://api.github.com/users/latviancoder/orgs","repos_url":"https://api.github.com/users/latviancoder/repos","events_url":"https://api.github.com/users/latviancoder/events{/privacy}","received_events_url":"https://api.github.com/users/latviancoder/received_events","type":"User","site_admin":false},"created_at":"2018-05-26T11:37:54Z","updated_at":"2018-05-26T11:37:54Z","author_association":"NONE","body":"I have similar requirement in my app and ended up doing the same thing @azangru is describing - setting custom flag inside of `values` object and submitting the form afterwards, with custom `validate` function. And because `setFieldValue` is async and doesnt return a promise I used setTimeout hack."}}
{"actor":{"display_login":"latviancoder"}}