clojure-spec

About: http://clojure.org/about/spec Guide: http://clojure.org/guides/spec API: https://clojure.github.io/spec.alpha/clojure.spec.alpha-api.html
kenny 2020-09-16T17:47:59.133100Z

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?

alexmiller 2020-09-16T17:52:47.133300Z

no way to do that

alexmiller 2020-09-16T17:53:37.134100Z

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

kenny 2020-09-16T17:55:54.134500Z

Yep - definitely in a gray area. Thanks.