Conditional Enum Values Based on selected value of another Enum

I’m trying to set the list of possible enum values for a field based on the selection of another enum using “AnyOf”, but not working:

              "dataSource": {
                "type": "string",
                "enum": [
                  "storm_report",
                  "weather_report",
                  "site_attributes"
                ]
              },
              "attribute": {
                "type": "string",
                "enum": [
                  "total_snowfall",
                  "storm_start_date",
                  "storm_end_date",
                  "pre_storm_temp",
                  "post_storm_temp",
                  "site_type"
                ]
              },

And then after all property definitions …

          "oneOf": [
              {
                "properties": {
                  "data_source": {
                    "enum": [
                      "storm_report"
                    ]
                  },
                  "attribute": {
                    "enum": [
                      "total_snowfall",
                      "storm_start_date",
                      "storm_end_date"
                    ]
                  }
                }
              },
              {
                "properties": {
                  "data_source": {
                    "enum": [
                      "weather_report"
                    ]
                  },
                  "attribute": {
                    "enum": [
                      "pre_storm_temp",
                      "post_storm_temp"
                    ]
                  }
                }
              }

If I make the conditional enum “required” then it does seem to be VALIDATING against it, but it wont actually display ONLY the desired values.

Hi @jeffhagins,

Our off-the-shelf renderers are not smart enough to dynamically collect the “valid” enum options. They will just look into the “originally” defined ones. However, as you noticed, validation will still work regardless.

If you like to only show “valid” enum options you will need to write a custom renderer. You can basically just reuse our MaterialEnumControl but modify the options which are handed over according to your use cases.