Create a new project:
➜ ~ mkdir demo
➜ ~ cd demo
➜ demo echo '{:deps {metosin/malli {:mvn/version "0.8.0-20220123.082237-3"}} :aliases {:dev {:extra-paths ["classes"]}}}' > deps.edn
Loading takes ages:
➜ demo clj -A:dev
Clojure 1.10.3
user=> (time (require '[malli.dev.pretty :as pretty]))
"Elapsed time: 6972.434167 msecs"
nil
user=>
Compiling malli stuff once one client-side:
➜ demo mkdir classes
➜ demo clj -A:dev -M -e "(binding [*compile-files* true] (require 'malli.dev))"
➜ demo clj -A:dev
Clojure 1.10.3
user=> (time (require '[malli.dev.pretty :as pretty]))
"Elapsed time: 487.331166 msecs"
nil
In action:
user=> (pretty/explain [:map [:age [:int {:min 18}]]] {:age 17})
-- Validation Error -------------------- NO_SOURCE_FILE:1 --
Value:
{:age 17}
Errors:
{:age ["should be at least 18"]}
Schema:
[:map [:age [:int {:min 18}]]]
More information:
https://cljdoc.org/d/metosin/malli/CURRENT
------------------------------------------------------------
{:schema [:map [:age [:int {:min 18}]]]
:value {:age 17}
:errors ({:path [:age]
:in [:age]
:schema [:int {:min 18}]
:value 17
:message "should be at least 18"})}
user=>