Fork me on GitHub
#malli
<
2022-11-20
>
aaron5100:11:48

Maybe I need to pass my own “report” function (defaults to -fail!) that throws a humanized error?

aaron5100:11:02

Seems like the report function doesn’t receive parameters that can be humanized…

ikitommi09:11:04

(mx/defn plus [x :- :int, y :- :int] (+ x y))

(mi/instrument! {:report (pretty/reporter)})

(plus "1" "2")

ikitommi09:11:44

reporter is a function to create it, takes a bunch of optional options.

ikitommi09:11:48

if you want to throw the humanized (instead of just printing it):

(mi/instrument! {:report (pretty/thrower)})

aaron5116:11:24

Awesome. Thank you!

ikitommi09:11:24

malli.provider defaults now to creating real schemas (e.g. :int) instead of predicate ones (e.g. int?):

(mp/provide [{:a [1 2 3]
              :b "kikka"
              :c true}
             {:a nil
              :b "kikka"
              :c "true"}])
;[:map 
; [:a [:maybe [:vector :int]]] 
; [:b :string] 
; [:c :some]]
+ also the :some schema.

❤️ 7