jsonforms icon indicating copy to clipboard operation
jsonforms copied to clipboard

Allow modifications of errors in non-redux version

Open DavidHenri008 opened this issue 5 years ago • 5 comments

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

DavidHenri008 avatar Aug 05 '19 18:08 DavidHenri008

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.

sdirix avatar Aug 07 '19 22:08 sdirix

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.

DavidHenri008 avatar Aug 08 '19 11:08 DavidHenri008

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.

sdirix avatar Aug 12 '19 08:08 sdirix

Any update on this issue? I have the similar requirements and non-redux version does not support them.

manju2791 avatar Jul 16 '21 10:07 manju2791

Hi @manju2791, no update yet. However I think the best way to implement this feature would be via JSON Forms middleware support.

sdirix avatar Jul 19 '21 08:07 sdirix

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.

sdirix avatar Nov 08 '22 21:11 sdirix