我正在尝试使用 plumatic-schema 对向量中的键值进行验证,但错误消息对我来说并不清楚,这就是我想要做的:
;validating array with maps, it works
(s/validate [{}] [{} {}])
=> [{} {}]
;validating array with key and map (any lenght), not work
(s/validate [s/Int {}] [0 {} 1 {}])
[Int {}] is not a valid sequence schema;
a valid sequence schema consists of zero or more `one` elements, followed by zero or more
`optional` elements, followed by an optional schema that will match the remaining elements.
我的问题是,你知道我做错了什么吗?而这个错误的真正含义是什么?
目标实际上是将此验证用于函数调用,
例如:
(s/defn example [items :- [(s/one s/Int "i") (s/one {} "v")]] ...)
;the call should be valid for cases like this
(example [0 {} 1 {} 2 {} 3 {}])
(example [0 {}])