我有一个名为::cell的自定义地图的规范,假设
(s/def ::attr-1 int?)
(s/def ::attr-2 int?)
(s/def ::cell :req-un [::attr-1 ::attr-2])现在我想要一个只包含这些::cell地图的自定义矢量的另一个规范::grid。例如,网格可能如下所示:
(let grid [{:attr-1 11, :attr-2 12} {:attr-1 21 :attr-2 22}])是否可以使用::cell规范为此需求创建规范
(s/def ::grid ???)发布于 2019-03-27 01:39:48
您可以使用tuple
(s/def ::grid (s/tuple ::cell ::cell ::cell))或指定种类和计数的coll-of:
(s/coll-of ::cell :kind vector? :count 3)https://stackoverflow.com/questions/55363047
复制相似问题