Oh, and another one:
https://github.com/metosin/spec-tools/blob/master/src/spec_tools/parse.cljc#L236 throws when spec is defined through a symbol
(s/def ::bar string?)
(s/def ::qix string?)
(s/def ::foo (s/keys :req-un [::bar]))
(s/def ::baz (s/keys :req-un [::qix]))
(spec-tools/merge ::foo ::bar)
;; works fine
(def bar ::bar)
(spec-tools/merge ::foo bar)
;; throws
PR welcome
(defmethod parse-form 'spec-tools.core/merge [_ form]
(let [type-priority #({:map 1
:multi-spec 0} (:type %) 0)]
(apply impl/deep-merge (->> (rest form)
(map parse-spec)
(sort-by type-priority)))))
makes the problem go away, but I’m not sure if it actually fixes the problem.
I’d be happy to submit a PR once i’ve played with it a bit.
This is just a switcheroo on the map lookup with a default value.
btw, would anyone be intersted in having a #malli coercion module for c-api? #reitit has that.
I’ll create an issue for now so I don’t forget to make the PR
st/coerce
doesn’t seem to work across s/*
I think none of the regex specs have coercion impl.
Seems like it from the comments 😞
Something like
(defmethod parse/parse-form 'clojure.spec.alpha/* [_ form]
{:type [:vector]
::parse/item (-> form second parse/parse-spec-with-spec-ref)})
Seems to work. I’m just trying stuff and seeing if it works.Oh, but there is more to it than that. (s/* )
returns a map
, so it seems as if parse-spec
needs to be taught about it.