add custom condition for properties in endpoint.json

I’m editing an “endpoint.json” schema with key-value pairs in the “properties” section. If the key is “xyz.Password,” I want only the data type of its corresponding value to change from “string” to “secureString.” Here’s the reference code for context –

   "schema":{
      "properties":{
         "type":{
            "dataType":"complex",
            "isMultiple":true,
            "fields":[
               {
                  "label":"Key",
                  "id":"prop_key",
                  "type":{
                     "dataType":"string"
                  },
                  "constraints":{

                  }
               },
               {
                  "label": "Value",
                  "id": "prop_value",
                  "type": {
                     "dataType": 'string'
               },
                  "constraints": {}
               }
            ]
         },
         "placeholder":"",
         "default":[
            {
               "prop_key":"Type",
               "prop_value":"Demo"
            }
         ],
         "constraints":{

         }
      }
   },
   "options":{

   }
}```

I  want to set the data type of "prop_value" dynamically based on the value of "prop_key" within a "datagrid." However, JSON schema definitions don't typically support dynamic evaluation of functions or conditions for data types. but my use case requires this kind of dynamic behavior, I might not be able to handle it within my application code.

I want to set a rule in the "Properties" section: Normally, the data type of the "Value" field should be "string," but if the "Key" is "abc.Password," then the data type of that specific "Value" should be changed to "secureString." 
I've been struggling with this issue for days and need your assistance.

Leave a Comment