Dynamically updating enums and issue with AJV

Hi again!

I’m looking for insight on a weird issue. Let me know if I’m in the wrong place.

We are dynamically updating the values of an enum in jsonforms like so:

Jsonforms initialized with default schema/values on page load → User uploads a CSV file → CSV headers are extracted → Inject headers into the enum property of the schema object → Re-initialize with updated schema.

This works and the drop down updates with new values. But sometimes, when we upload a CSV the AJV’s ‘allowed values’ are not updated with the new values. This might be confusing but see screen shot below. The value I selected is AFTER a new enum has been initialized.

It is my understanding that when initializing the jsonforms with the default AJV, validation for enums are generated? But perhaps on occasion when dynamically changing definitions and reinitializing, there might be a cache issue. I can confirm that the schema does update with the right enum/definitions

Let me know if I can help clarify anything confusing.

[original thread by Ricardo Guntur]

Thanks for your message. In general I expect that your approach should work (which it does sometimes?). When you execute the setSchema action, the validator is replaced with a new compile result of Ajv, therefore everything should be up to date.

We need some more information to pinpoint the cause of the problem. As a first measure it would be great if you could post a minimal example in which this problem occurs. Secondly you could check whether the problem is caused by JSON Forms or Ajv by manually re-running the validation yourself with the same Ajv instance outside of JSON Forms.

[maulik-modi]

@ricardo-guntur(ricardo-guntur) , were you able to resolve your issue with comments from @sdirix(sdirix)