Closed marlondc closed 2 years ago
I removed this in v4. Would need a case to add it back
This method was useful for having a error handler component then you can distinguish which errors should be shown at field level or which ones at general level
Assuming this error field from an API errors: [{ messages: [string]; path: string }]
<ErrorsWrapper>
<Alert severity="error">
<Title>{t("common:errors")}</Title>
{errors.map(e => {
if (e.path === "base") {
return e.messages.map(m => <Error key={m}>{m}</Error>)
}
// used to show errors that are produced by hidden fields and cannot be represented on the field that caused the error
if (!fieldExists(e.path)) {
return e.messages.map(m => <Error key={m}>{`${t(e.path)} ${m}`}</Error>)
}
return null
})}
</Alert>
</ErrorsWrapper>
https://github.com/joepuzzo/informed/pull/44 added FieldExists to FormApi but it's not typed in the index.d.ts
I can make a PR to add FieldExists to the FormApi types if you want.