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
2021-03-23T15:01:31.010600Z

Hi, I was wondering, when one has a repeating spec (e.g. non-empty string, something like a type) in spec2, what is more idiomatic: a) simply define the spec behind a keyword, e.g.

(s/def ::non-empty-string (s/and- string? (comp not str/blank?)) 

(s/def :foo/bar ::non-empty-string)
or b) make non-empty-string a spec op, e.g.
(s/defop non-empty-string [] (s/and- string? (comp not str/blank?)))

(s/def :foo/bar (non-empty-string))