cljs.spec.alpha/explain-printer
(explain-printer ed)
Source docstring:
Default printer for explain-data. nil indicates a successful validation.
(defn explain-printer
[ed]
(if ed
(let [problems (->> (::problems ed)
(sort-by #(- (count (:in %))))
(sort-by #(- (count (:path %)))))]
(print
(with-out-str
(doseq [{:keys [path pred val reason via in] :as prob} problems]
(pr val)
(print " - failed: ")
(if reason (print reason) (pr (abbrev pred)))
(when-not (empty? in)
(print (str " in: " (pr-str in))))
(when-not (empty? path)
(print (str " at: " (pr-str path))))
(when-not (empty? via)
(print (str " spec: " (pr-str (last via)))))
(doseq [[k v] prob]
(when-not (#{:path :pred :val :reason :via :in} k)
(print "\n\t" (pr-str k) " ")
(pr v)))
(newline)))))
(println "Success!")))