jsonforms
jsonforms copied to clipboard
Allow modifications of errors in non-redux version
Is your feature request related to a problem? Please describe. In order to translate AJV error messages, the errors should be passed to the renderer.
Describe the solution you'd like The errors handling on the JsonForms component is partially supported:
export const JsonForms = (
props: JsonFormsInitStateProps & JsonFormsReactProps
) => {
const {
ajv,
data,
schema,
uischema,
renderers,
refParserOptions,
onChange
} = props;
return (
<JsonFormsStateProvider
initState={{
core: {
ajv,
data,
refParserOptions,
schema,
uischema,
errors: [] // TODO
},
renderers
}}
>
<JsonFormsDispatch onChange={onChange} />
</JsonFormsStateProvider>
);
};
Describe for which setup you like to have the improvement Framework: react RendererSet: all
Thanks for your interest in JSON Forms. Note that the errors are already passed down to the renderers as they need access to them to render the error messages.
We recently merged functionality which allows you to translate the provided errors with a new "update errors" action. See https://github.com/eclipsesource/jsonforms/pull/1457 for an example. This will work for all redux-based renderer sets.
The updateErrors
action looks nice with Redux, but in my case, I do not use Redux.
With the onChange
callback I do get errors but does changing them will have an effect on the displayed text in the renderer?
Also, as shown in my original post, the jsonForms component does not accept errors array but rather create a new empty array.
Thanks for the detailed information. I updated the issue accordingly. Note that we have a lot of stuff planned for the next releases, so this issue might not be worked on for a while. I added it to the next
milestone, e.g. 2.4.0
, for now. If you'd like to open a PR yourself we will definitely take a look.
Any update on this issue? I have the similar requirements and non-redux version does not support them.
Hi @manju2791, no update yet. However I think the best way to implement this feature would be via JSON Forms middleware support.
This is now supported via the new additionalErrors
feature for JSON Forms 3.0. In case errors need to be modified the validation can be run outside of JSON Forms and the errors handed over via additionalErrors
. See here for the documentation.