strip-extra-keys-transformer not working with s/or if ors predicates are non- map validating specs
tylernisonoff opened this issue · comments
This is similar to Issue 178 (Fixed by PR 219, but for a specific case.
I'm not sure if this is intended, but it was surprising to me.
Consider the following case where we want to allow something like either {:a 1}
or {:b "foo"}
(s/def ::a int?)
(s/def ::b string?)
(s/def ::c (s/or
:a (s/keys :req-un [::a])
:b (s/keys :req-un [::b])))
((s/valid? ::c {:a 1})
; => true
(st/coerce ::c {:a 1} st/strip-extra-keys-transformer)
; => {}
However, If i change ::c
to:
(s/def ::c (s/or
:a (st/spec (s/keys :req-un [::a]))
:b (st/spec (s/keys :req-un [::b]))))
NOTE: the st/spec
s
Now we get:
(s/valid? ::c {:a 1})
; => true
(st/coerce ::c {:a 1} st/strip-extra-keys-transformer)
; => {:a 1}
My expectation is either of these two should be able to be coerced, is that correct?