拥有描述规格表单的规范将很有用,这样就可以从像 (s/keys :req [::a ::b] :opt [::c]) 这样的规格表单到让你能抓取部分的符合版本,而不必解析 s 表达式。这可以通过创建规格来实现,因此允许
user=> (require '[clojure.spec :as s] '[clojure.spec.specs])
user=> (s/def ::aspec (s/keys :req [::a ::b] :opt [::c]))
user=> (def aspec-data (s/conform :clojure.spec.specs/spec (s/form ::aspec)))
user=> (pr aspec-data)
[:form {:s clojure.spec/keys,
:args {:req [[:key :clojure.spec.specs/a] [:key :clojure.spec.specs/b]],
:opt [:clojure.spec.specs/c]}}]
user=> (map val (-> aspec-data val :args :req))
(:clojure.spec.specs/a :clojure.spec.specs/b)
*修正方案:* spec-forms.patch (正在进行中)