-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
We now have multiple components with complex errors: file upload, children, partners, profile.
All have a similar complex setup:
const {error: formikError} = getFieldMeta(name);
// We can have individual file errors (because the intrinsic value type of the
// component is FileUploadData[]), a string error for the component as a whole or even
// deeply nested errors for a file in value array. The types from Formik are very wrong,
// which is why we need the cast. We also can't use the useFieldError hook because it's
// meant for components with a single/multiple mode, but file components *always* have an
// array of file uploads, even if multiple files are not allowed.
const error = formikError as unknown as
| undefined
| string
| (string | FormikErrors<FileUploadData>)[];This complex structure is needed because getFieldMeta() assumes error is always a string, which is not the case for these components.
We should implement a proper setup for dealing with these kinds of complex error structures. Like #213 (comment) suggested, perhaps a asComplexDataError hook, or extension on useFieldError, that deals with this complexity.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels