Skip to content

Commit

Permalink
prettifier
Browse files Browse the repository at this point in the history
  • Loading branch information
ikitommi committed Mar 25, 2022
1 parent 7fada5b commit 400dc0c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/malli/dev/pretty.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@
(let [message (with-out-str (report type data))]
(throw (ex-info message {:type type :data data})))))))

(defn prettier [key title f options]
(defn prettifier [type title f options]
(let [printer (assoc (or (::printer options) (assoc (-printer) :width 60)) :title title)
actor (::actor options reporter)]
(fn [] (when-let [res (f)] ((actor printer) key res) res))))
(fn [& args] (when-let [res (apply f args)] ((actor printer) type res) res))))

(defn explain
([?schema value] (explain ?schema value nil))
([?schema value options]
(let [explain (fn [] (->> (m/explain ?schema value options) (me/with-error-messages)))]
((prettier ::m/explain "Validation Error" explain options)))))
((prettifier ::m/explain "Validation Error" explain options)))))

0 comments on commit 400dc0c

Please sign in to comment.