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