Nested anyOf not working

I have a simple case that I am not able to understand how to do it.
I have 3 boolean controls, Parent, childA, childB.
If parent is true then at least one of the children must be true.
Below is my JSONForm schema and UI Schema and it can be tested in any online playground.

NOTE: if in the below JSON Schema I change then->anyOf to then->allOf then validation works perfectly but that’s not what I am trying to achieve.

Thanks a lot in advance for your time.

JSON Schema

{
  "type": "object",
  "properties": {
    "parent": {
      "type": "boolean"
    },
    "childA": {
      "type": "boolean"
    },
    "childB": {
      "type": "boolean"
    }
  },
  "if": {
    "properties": {
      "parent": {
        "const": true
      }
    }
  },
  "then": {
    "required": [
      "parent",
      "childA",
      "childB"
    ]
  },
  "else": {
    "required": [
      "parent"
    ]
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "parent": {
            "const": true
          }
        }
      },
      "then": {
        "anyOf": [
          {
            "properties": {
              "childA": {
                "const": true
              }
            }
          },
          {
            "properties": {
              "childB": {
                "const": true
              }
            }
          }
        ]
      }
    }
  ]
}

UI Schema

{
  "type": "VerticalLayout",
  "elements": [
    {
      "type": "Control",
      "label": "Parent",
      "scope": "#/properties/parent"
    },
    {
      "type": "Control",
      "label": "Child A",
      "scope": "#/properties/childA"
    },
    {
      "type": "Control",
      "label": "Child B",
      "scope": "#/properties/childB"
    }
  ]
}

Hi @alyjee,

Our filtering logic does not consider the case at hand. This is why although the errors are produced internally, they are not shown in the UI.

We could try to improve the filtering so that in this case the errors are not removed, this would result in a UI like this (just a demo):

parent-child

1 Like

thanks a lot for the quick response. It would be great to have this.

Hi @alyjee, I did not yet implement it. For the demo I just hard coded the filtering to your example. If you like you can take a stab at it and contribute a solution to JSON Forms.

1 Like