-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