Fork me on GitHub
#clojure-spec
<
2021-03-23
>
ognen.ivanovski15:03:31

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))