(conformer f) (conformer f unf)
takes a predicate function with the semantics of conform i.e. it should return either a (possibly converted) value or :clojure.spec/invalid, and returns a spec that uses it as a predicate/conformer. Optionally takes a second fn that does unform of result of first
(require '[clojure.spec :as s])
(s/def ::string-AB-seq (s/cat :a #{\\A} :b #{\\B}))
; Strings are not considered as sequences of character by default
(s/conform ::string-AB-seq "AB")
;; => :clojure.spec/invalid
(s/def ::string-AB
(s/and
; conform as sequence (seq function)
(s/conformer seq)
; re-use previous sequence spec
::string-AB-seq))
; Now we can spec a string as a sequence of character!
(s/conform ::string-AB "AB")
;; => {:b "B", :a "A"}