No error displaying for conditionally required fields

Hi, I’m trying to use the schema below with JsonForms. It generates my UI elements in React and will not me from submitting the form unless I have one of or both ‘toCurrencyCode’ or ‘fromCurrencyCode’ set.

This is fine, however there is no red error box or message appearing. The errors work when explicitly setting the fields as required but I only want them to be marked as an error when both are empty. Been scratching my head over this and it’s not the only approach I’ve tried.

Any help would be appreciated, thanks.

{
    "schema": {
      "type": "object",
      "properties": {
        "fromDate": {
          "type": "string",
          "format": "date",
          "options": {
            "isStrict": false,
            "optionLabel": "name",
            "optionValue": "value"
          }
        },
        "toDate": {
          "type": "string",
          "format": "date",
          "options": {
            "isStrict": false,
            "optionLabel": "name",
            "optionValue": "value"
          }
        },
        "fromCurrencyCode": {
          "type": "string"
        },
        "toCurrencyCode": {
          "type": "string"
        },
        "snapCode": {
          "type": "string",
          "enum": [
            "Code1",
            "Code2",
            "Code3",
            "Code4"
          ],
          "options": {
            "isStrict": false
          }
        }
      },
      "anyOf": [
        {"required": ["fromCurrencyCode"]},
        {"required": ["toCurrencyCode"]}
      ],
      "required": [
        "fromDate",
        "toDate"
      ]
    }
 }

I’ve worked around this issue by adding a “dependsOn” param to each of my fields and storing any dependent relationship in a map. map<nameOfDependentFieldString, value>

In a custom renderer I then set the error prop on my Json Forms object by checking the dependency map to see if the dependent field has a value or not.

If both are blank the error gets enabled on both. At least one filled removed the errors.

    "schema": {
      "type": "object",
      "properties": {
        "fromDate": {
          "type": "string",
          "format": "date"
        },
        "toDate": {
          "type": "string",
          "format": "date"
        },
        "fromCurrencyCode": {
          "type": "string",
          "dependsOn": "toCurrencyCode"
        },
        "toCurrencyCode": {
          "type": "string",
          "dependsOn": "fromCurrencyCode"
        }
      },
      "required": [
        "fromDate",
        "toDate"
      ]

Hi @Brian950,

I would have expected that the first schema marks both of the fields (i.e. fromCurrencyCode, toCurrencyCode) as required until one of them is filled. If that doesn’t work then we probably filter the anyOf errors in that case. We could think about changing this in JSON Forms.

Your second approach of using a custom renderer of course works too.