stackworx / formik-mui

Bindings for using Formik with Material-UI

Home Page:https://stackworx.github.io/formik-mui

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Validation isn't triggered when file is selected

fc opened this issue Β· comments

commented

Current Behavior 😯

Select a file to upload using the SimpleFileUpload component that fails validation and see that it does not display an error message

Expected Behavior πŸ€”

Shows error immediately if selected file does not pass validation.

Steps to Reproduce πŸ•Ή

  1. Go here https://codesandbox.io/s/great-pare-3fk5z?file=/src/index.tsx
  2. Select a file
  3. Click submit

A suggested fix

Call setFieldTouched(field.name, true) in the onChange callback.

Why is the file key inside the value interface have only two allowed types i.e. a File and an empty string?
interface Values { file: '' | File; }
The problem is the errors also have the Partial Value type and I am not able to assign it a string
(If I am not wrong the values inside the error object are displayed as error)