Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法使用clojure架构库在映射中使用字符串键验证值_Clojure_Plumatic Schema - Fatal编程技术网

无法使用clojure架构库在映射中使用字符串键验证值

无法使用clojure架构库在映射中使用字符串键验证值,clojure,plumatic-schema,Clojure,Plumatic Schema,我尝试使用clojure的prismatic/schema库验证映射。这是我的形状 (require '[schema.core :as s]) (def d {"a" s/Str "b" s/Int}) 当我试图根据映射验证它时,它抛出以下异常 (s/validate d {"a" "@@#$" "b" 2}) RuntimeException More than one non-optional/required key schemata: ["a" "b"] schema.core/f

我尝试使用clojure的prismatic/schema库验证映射。这是我的形状

(require '[schema.core :as s])
(def d {"a" s/Str "b" s/Int})
当我试图根据映射验证它时,它抛出以下异常

(s/validate d {"a" "@@#$" "b" 2})
RuntimeException More than one non-optional/required key schemata: ["a" "b"]  schema.core/find-extra-keys-schema (core.clj:705)
是我做错了什么,还是架构库不能根据字符串键进行验证?

您必须使用

(def d {(s/required-key "a") s/Str (s/required-key "b") s/Int})

example=> (def d {(s/required-key "a") s/Str (s/required-key "b") s/Int})
#'schema-examples/d
example=> (s/validate d {"a" "@@#$" "b" 2})
{"a" "@@#$", "b" 2}
examples=>