I have an alpaca schema with an array of conditional dependencies. Each value in the array has a known prefix. Instead of using an array, is it possible to use a function/conditional that checks a value in a certain field to determine if that value has the known prefix and results in the dependent field being shown?
This question (conditionally require a field) is related to the problem I'm facing (how to get and check the value of a field in a function).
Note: One site may be categorised in more than one type, hence the TypePrefix0
on the value.
This is the code in question, as it currently stands:
"schema": {
"properties": {
"tpl": { "type":"string" },
"site": { // optionTree
"type":"string",
"title":"Site",
"required": true
},
"sourceType": {
"type":"string",
"title":"Source Type",
"enum":['area','group'],
},
"dataType": {
"type":"string",
"title":"Data Type",
"enum":['people','vehicles', '*']
},
},
"dependencies": {
"dataType": ["sourceType", "site"]
}
},
"options": {
"fields: { // reduced to relevant parts
"dataType": {
"dependencies: {
"sourceType": "group",
// site values shown here are not actual values used in production
"site": ["TypePrefix0.site0", "TypePrefix0.site1", "TypePrefix0.site2", /*...*/]
// how do/can I replace the array with a function/condition:
// (site.value.startsWith("TypePrefix0.")) : true
}
}
}
}