If else Validation not happening on nested data

Hello I am new to Jsonforms and i am trying to do if then validation for a nested schema.
I have my schema mentioned below i want the firstname to be required when the enum option is b and when it’s a or c it shouldnt be required.

I can see ajv errors in console with this schema in console but cannot see in the ui getting rendered below the input field for firstname

{
  "definitions": {
    "data": {
      "type": "object",
      "properties": {
        "startswith": {
          "type": "string",
          "enum": ["a", "b", "c"],
          "minLength": 1
        },
        "fullname": {
          "type": "object",
          "properties": {
            "firstname": {
              "type": "string",
              "enum": ["d", "e", "f"]
            },
            "lastname": {
              "type": "string",
              "minLength": 1
            }
          }
        }
      },
      "required": ["startswith"],
      "if": {
        "properties": {
          "startswith": {
            "enum": ["b"]
          }
        }
      },
      "then": {
        "required": ["firstname"]
      }
    }
  },
  "type" : "object",
  "properties" : {
    "data" : {
      "type" : "array",
      "items": {
        "$ref" : "#/definitions/data"
      }
    }
  }
}

This should do the trick not sure if there are better ways out there

{
  "definitions": {
    "data": {
      "type": "object",
      "properties": {
        "startswith": {
          "type": "string",
          "enum": ["a", "b", "c"],
          "minLength": 1
        },
        "fullname": {
          "type": "object",
          "properties": {
            "firstname": {
              "type": "string",
              "enum": ["d", "e", "f"]
            },
            "lastname": {
              "type": "string",
              "minLength": 1
            }
          }
        }
      },
      "required": ["startswith"],
      "if": {
        "properties": {
          "startswith": {
            "enum": ["b"]
          }
        }
      },
      "then": {
        "type": "object",
	  "properties" : {
	    "fullname" : {
		 "type" : "object",
		 "required" : [
		  "firstname"
		 ]
	     }
	   }
      }
    }
  },
  "type" : "object",
  "properties" : {
    "data" : {
      "type" : "array",
      "items": {
        "$ref" : "#/definitions/data"
      }
    }
  }
}
2 Likes

Thanks @howdyAnkit This helped