I have an import:
import type { ErrorObject } from "ajv";
A const:
const [validationErrors, setValidationErrors] = useState<Array<ErrorObject>>([]);
And code to return the errors to the const
<JsonForms
schema={schema}
uischema={uiSchema}
data={document}
renderers={materialRenderers}
cells={materialCells}
onChange={({ data, errors }) => {
setDocument(data);
if (errors != undefined) {
setValidationErrors(errors);
}
}}
/>
The ajv ErrorObject doesn’t appear to have additional properties such as .interfacePath and .parentSchema.title
Firstly is there an enhanced ErrorObject local to JSONForms I should be using?
Secondly TS doesn’t like my setValidationErrors(errors):
Argument of type ‘ErrorObject<string, Record<string, any>, unknown>’ is not assignable to parameter of type ‘SetStateAction<ErrorObject>’.
Type ‘ErrorObject<string, Record<string, any>, unknown>’ is not assignable to type ‘ErrorObject’.
Property ‘dataPath’ is missing in type ‘ErrorObject<string, Record<string, any>, unknown>’ but required in type ‘ErrorObject’.ts(2345)
ajv.d.ts(300, 5): ‘dataPath’ is declared here.
(parameter) errors: ErrorObject<string, Record<string, any>, unknown>
Has anyone tried to do similar? I’m passing the Array of ErrorObject’s to a banner component to then display the errors as a list.
Any thoughts greatly appreciated.
Rob.