malli

Joel 2025-06-13T04:25:14.797489Z

Is there an https://github.com/bhb/expound like library for malli? I saw early posts on this forum looking to implement something like expound, unfortunately the “humanized errors” are too verbose as they stand, so curious if there’s some relief in that regard.

2025-06-16T18:45:31.330649Z

explain-malli options documented here: https://github.com/paintparty/bling?tab=readme-ov-file#options-for-explain-malli

2025-06-16T18:46:32.438109Z

:callout-opts is what you would use to change the underlying callout label text (top header)

2025-06-16T18:47:55.440389Z

Options for the underlying callout documented here: https://github.com/paintparty/bling?tab=readme-ov-file#callout-blocks

2025-06-16T18:49:43.867319Z

Here’s a bunch of examples you can try on your side w/various options:

(require '[bling.explain :refer [explain-malli]])

(def Address
  [:map
   [:id string?]
   [:tags [:set keyword?]]
   [:address
    [:map
     [:street string?]
     [:city string?]
     [:zip int?]
     [:lonlat [:tuple double? double?]]]]])

(def v 
  {:id      "Lillan"
   :tags    #{:artesan "coffee" :garden}
   :address {:street "Ahlmanintie 29"
             :city   "Tempare"
             :zip    33100
             :lonlat [61.4858322, 87.34]}})

(explain-malli Address v {:display-schema? false :callout-opts {:label "Custom Label"}})

(explain-malli Address v {:display-schema? false :callout-opts {:label "Custom Label" :label-theme :minimal}})

(explain-malli Address v {:display-schema? false :callout-opts {:label "Custom Label" :theme :sideline-bold}})

(explain-malli Address v {:display-schema? false :callout-opts {:label "Custom Label" :theme :sideline-bold :label-theme :minimal}})

(explain-malli Address v {:display-schema? false :callout-opts {:label "Custom Label" :theme :gutter}})

(explain-malli Address v {:display-schema? false :callout-opts {:label "Custom Label" :theme :gutter :label-theme :minimal}})

(explain-malli Address v {:display-schema? false :callout-opts {:label "Custom Label" :theme :gutter :margin-left 3 :label-theme :minimal}})

Steven Lombardi 2025-06-26T03:31:42.246419Z

Glad I found this thread. I need something similar, but I thought maybe just filtering out valid keys in maps would be sufficient. And for seqs, possibly just converting to a map of int (the idx) to error. But I'm assuming the problem is more complex than that.

2025-06-14T10:59:37.945829Z

@ambrosebs thanks for the referral! The new bling.explain/explain-malli function is now included the https://clojars.org/io.github.paintparty/bling. @joel380 Thanks for the ticket, I https://github.com/paintparty/bling/issues/38#issuecomment-2972605044. Let me know if you have any luck with the latest version. As far as compactness you can set :display-schema? to false and :spacing to :compact as https://github.com/paintparty/bling?tab=readme-ov-file#options-for-explain-malli

2025-06-14T18:57:24.607359Z

@joel380 yeah the :or handling is too verbose. I think other solutions have similar issues. I outlined some heuristics we could try implementing here https://clojurians.slack.com/archives/CLDK6MFMK/p1748559223421159?thread_ts=1748550434.774499&cid=CLDK6MFMK

Joel 2025-06-14T22:08:57.026209Z

@jcoyle Is there also a way to change “Malli Validation Error” (top header)?

Joel 2025-06-13T14:26:00.382239Z

So the value for us is often page(s) and the schema is at least a whole page (the whole registry), so while the info is there it’s definitely an overload with a bunch of irrelevant information. I’ll give bling a try, if it can highlight where the errors are that could be helpful, although it would be nice if it could make it concise as well.

2025-06-13T18:07:46.549659Z

It might be constructive to read the 3-4 threads gathering feedback about bling starting here https://clojurians.slack.com/archives/CLDK6MFMK/p1748550311357469

👍🏼 1
2025-06-13T18:08:06.412699Z

I think I had a couple of ideas for concision.

Joel 2025-06-13T19:37:37.992459Z

Pretty sure I found a bug with bling, which I’ll file a ticket for as it looks pretty promising, but maybe not quite there yet.

👍 1
2025-06-13T19:48:52.040559Z

Was there a specific problem with humanized errors that made it too verbose?

Joel 2025-06-13T20:42:03.104149Z

I’m finding one problem

::test-specs [:or ::test-spec [:sequential ::test-spec]]}
I think what was happening is if there was a problem somewhere in test-specs, it was thinking it should dump out everything, because of this part of the spec(?). I tried separating the explain into validating single vs multiple, and that seems to largely remedy the problem for value :), but it doesn’t pare down the schema dump at all :(. With that remedied, I think the error messages are more geared toward a schema writer, not a user. I like that expound/bling attempt to suggest how to fix. I tend to get “invalid type” from malli humanize and that’s of little use, especially when you can’t easily find it in the schema registry. Also, I wish the file/row was clickable in intellij, I couldn’t figure out how to reformat that.

➕ 1
Joel 2025-06-13T20:56:10.435929Z

I did still get an error like this… it’s indicating the position of the error.

(...
                     ...
                     ...
                     ...
                     ...
                     ...
                     ...
                     ...
                     [{} "this stuff didn't validate"]
                     ...
                     ...
                     ...
                     ...
                     ...
                     ...
                     ...
                     ...
                     ...
                     ...
                     ...
                     ...
                     ...
                     ...
                     ...
                     ...
                     ...
                     ...
                     ...
                     ...)
It could drop the following elides at least… sometimes this could be addition couple of pages.