我正在使用空手道來驗證端點答案。我的 API 以鍵值結構回答。問題是該值可能是布林值或字串。
我怎樣才能用這個或空手道的一個運算式來驗證這一點?
答案示例:
{
"value": true,
"key": "key1"
},
{
"value": "This is my value",
"key": "key2"
}
我嘗試過類似的事情
onfStructure: "#? _ == ^*(confStructure1 || confStructure2)"
confStructure1:
value: "#boolean"
key: "#string"
confStructure2:
value: "#string"
key: "#string"
要么
confStructure: "#? _ == (^*confStructure1 || ^*confStructure2)"
要么
confStructure:
value: "#(^*newSchema)"
key: "#string"
newSchema:
value: "#boolean"
value: "#string"
但沒有任何作業。
uj5u.com熱心網友回復:
這是我能想到的解決這個問題的唯一方法。有時不能使用空手道“模式”。老實說,大多數 API 從來沒有這種模式變化。
* def response = [{value: 'foo'},{value: true}]
* match each response == { value: "#? typeof _ == 'string' || typeof _ == 'boolean'" }
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/455079.html
