Fork me on GitHub
#clojure-spec
<
2020-09-16
>
kenny17:09:59

Is there a way to not include a key when using s/coll-of + kind map? + conform-keys true? For example,

(s/conform
  (s/coll-of
    (s/and (s/tuple #{"a"} boolean?)
           (s/conformer (fn [[_ v]] nil)))
    :kind map?
    :conform-keys true)
  {"a" true})
=> {nil nil}
That behavior seems correct. Curious if there's a way to indicate to not include the key though. Perhaps only way is to s/and in a conformer that removes nil keys?

Alex Miller (Clojure team)17:09:37

in general, use of conformers to do arbitrary transforms is considered an anti-pattern (conformer really exists for building new spec types primarily)

kenny17:09:54

Yep - definitely in a gray area. Thanks.