conditional dependencies의 배열을 가진 alpaca 스키마가 있습니다. 배열의 각 값에는 알려진 접두사가 있습니다. 배열을 사용하는 대신 특정 필드의 값을 검사하여 해당 값에 알려진 접두사가 있고 종속 필드가 표시되는지 확인하는 function/conditional을 사용할 수 있습니까?배열 대신 함수를 사용하여 알파카 조건부 종속성을 만드는 방법은 무엇입니까?
이 질문 (conditionally require a field)은 내가 직면 한 문제 (함수의 필드 값을 얻고 확인하는 방법)와 관련이 있습니다.
참고 : 하나의 사이트가 두 개 이상의 유형으로 분류 될 수 있으므로 값이 TypePrefix0
입니다. 그것은 현재의 약자로
이
는 문제의 코드입니다 : 는optiontree
컨트롤을 사용하는 대신
"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
}
}
}
}