spec-tools
spec-tools copied to clipboard
`select-spec` removing keys when using `s/or`
Hi, as I was using this library I ran into what I think is a small bug w/ select-spec
.
The bug seems to stem from using s/or
. The following test highlights the invalid code (you'll see it referenced in a linked commit).
(s/def ::str-264 string?)
(s/def ::kw-264 keyword?)
(s/def ::map-264 (s/or :str-map (s/keys :req [::str-264])
:kw-map (s/keys :req [::kw-264])))
(deftest issue-264
(doseq [check [{::kw-264 :foo}
{::str-264 "bar"}]]
(testing "specs are valid before calling st/select-spec"
(is (s/valid? ::map-264 check)))
(testing "specs stay valid after calling st/select-spec"
;; This line fails b/c select-spec returns {}
(is (s/valid? ::map-264 (st/select-spec ::map-264 check))))))