Get Errors for used fields only

Hi Team,

I can access the form data, errors from core object of useJsonForms hooks inside custom rendererd and through jsonForms onChange function, but the thing is I’m getting errors array which holds all the errors of fields defined in jsonSchema, but I need only errors defined in uiSchema.

Example: I have defined a jsonSchema with properties contains 4 mandatory fields, but in uiSchema I have used only 2 fields, Basically on Form UI, it will show only 2 fields. Onchange of JsonForms, Im getting errors for all the fields present in JsonSchema.

errors = [{field1},{field2},{field3},{field4}]

But i want errors array that should have elements i added via uiSchema.

Is there any built-in way to achieve that ?

Looking for solution…

Thanks in Advance!


Hi @Suseendhiran,

There is no built-in way to achieve this. Internally JSON Forms uses Ajv and always determines the errors for the whole JSON Schema. Then during rendering, each control has full access to all errors and just displays the ones which are relevant to them.

Conceptually, each renderer has full sovereignty of their rendered output, so JSON Forms can not know which errors the renderers decide to show.

What you could do is: