# Dynamically updating enums and issue with AJV

**URL:** <https://jsonforms.discourse.group/t/dynamically-updating-enums-and-issue-with-ajv/87>\
**Category:** General\
**Created:** [September 19, 2019, 6:09pm UTC](https://jsonforms.discourse.group/t/dynamically-updating-enums-and-issue-with-ajv/87 "2019-09-19T18:09:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![discobot](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/discobot/32/3_2.png) [@discobot](https://jsonforms.discourse.group/u/discobot)\
**Post date:** [September 19, 2019, 6:09pm UTC](https://jsonforms.discourse.group/t/dynamically-updating-enums-and-issue-with-ajv/87/1 "2019-09-19T18:09:23Z")

</div>

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.

[[Album] imgur.com ![](https://global.discourse-cdn.com/free1/uploads/jsonforms/original/1X/ff233596318d024ac563a90c655364032673a552.jpeg "imgur.com") ](https://imgur.com/a/vlZM1YR)

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](https://spectrum.chat/jsonforms/general/dynamically-updating-enums-and-issue-with-ajv~c08953fa-77ce-4221-a780-d3bb3b784fd3) by Ricardo Guntur]_

---

<div class="post-metadata">

**Author:** ![sdirix](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/sdirix/32/1073_2.png) [@sdirix](https://jsonforms.discourse.group/u/sdirix)\
**Post date:** [September 20, 2019, 7:13am UTC](https://jsonforms.discourse.group/t/dynamically-updating-enums-and-issue-with-ajv/87/2 "2019-09-20T07:13:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![discobot](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/discobot/32/3_2.png) [@discobot](https://jsonforms.discourse.group/u/discobot)\
**Post date:** [March 11, 2021, 10:48am UTC](https://jsonforms.discourse.group/t/dynamically-updating-enums-and-issue-with-ajv/87/3 "2021-03-11T10:48:00Z")

</div>

_[maulik-modi]_

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