-2
我在驗證clojure棱鏡模式時遇到問題。這是代碼。clojure模式驗證
:Some_Var1 {:Some_Var2 s/Str
:Some_Var3 (s/conditional
#(= "mytype1" (:type %)) s/Str
#(= "mytype2" (:type %)) s/Str
)}
我想使用的代碼來驗證它:
"Some_Var1": {
"Some_Var2": "string",
"Some_Var3": {"mytype1":{"type":"string"}}
}
但它扔我一個錯誤:
{
"errors": {
"Some_Var1": {
"Some_Var3": "(not (some-matching-condition? a-clojure.lang.PersistentArrayMap))"
}
}
}
這是一個非常基本的代碼,我試圖驗證。我對clojure很陌生,仍然在努力學習它的基礎知識。
謝謝,
感謝您的回覆,但我仍然無法解決問題。請你能告訴我,條件類型需要什麼類型的結構化輸入。如何在條件語句中選擇mytype1。 – peejain
使用'conditional',每個子句按順序進行評估。在你的例子中,%的值將爲: {「mytype1」{「type」「string」}} 請注意,該值沒有鍵':type',即使它有':type 'map to''string「'而不是''mytype」'。 – bbrinck