Errors in json forms not updating on large number of changes

Hello, thanks for your work.

When we initialize the form, a large number of fields change, and for some reason, if you go to the page through programmatic navigation (if you refresh the page in the browser, everything is fine), there are 17 errors in “core.errors”, while in “core.ajv.errors” there are only one error (which is correct) as valid data is present.

At the same time, in “coreDataToUpdate”, there are some objects (I don’t know if this affects the validation in this case), and everywhere there is correct data, but for some reason the validation occurs without taking into account the most recent changes in data.
Values in data are substituted via $set (vue2)

Dependencies:
@jsonforms/core”: “2.5.2”,
@jsonforms/vue2”: “2.5.2”,

That is, to summarize, I have a form in which values are substituted during mounting, including in a nested object, and after inserting it into the ajv object, the form was validated correctly, but in the core, the validation errors are not correct, there are errors written on the fields that are already were filled.

I would be grateful for help, or the path I need to take.

image
Unfortunately, I could only add 1 media file, so I’m attaching a screenshot with ajv errors

Hi @CodeXiD,

That is, to summarize, I have a form in which values are substituted during mounting, including in a nested object, and after inserting it into the ajv object, the form was validated correctly, but in the core, the validation errors are not correct, there are errors written on the fields that are already were filled.

Can you elaborate and ideally post the code of what is exactly happening there?

Good day, here is a minimal working example, if you open the browser console on the page with the form, you will see the following log “### this.refs {json-forms: VueComponent}”, which refers to the ref of the json-forms component.
Going through the object “[“json-forms”].jsonforms.core.errors” we will see 2 errors (which is no longer true, since we have already substituted values in these fields), and if we look here “[“json-forms” ].jsonforms.core.ajv.errors”, we will see that the value is null and there are no errors (which is correct).

Hi @CodeXiD,

JSON Forms expects that the handed over data prop has a different identity whenever its content changes. In the example code some deep properties are modified without changing the parent object itself. Therefore JSON Forms does not realize that it needs to re-execute validation.

I can recommend lodash’s fp/set which not only adapts the property to change but also recreates all parent objects/arrays. When handing over this new data object to JSON Forms it should behave as you expect.

Thanks for the reply, I modified the example in the link above by changing this.$set to _.set, but that didn’t really solve the problem, and also lost reactivity. But the most important thing is that there are still no errors in ajv, but there are in core.errors :cry:

Lodash’s fp/set does not change the data under question but returns a new object. You need to assign this new object, otherwise it’s just a no-op.

Thanks for your help, you are awesome! :slightly_smiling_face:
Everything worked out :+1:

1 Like