Fork me on GitHub
#malli
<
2020-02-19
>
ikitommi17:02:34

(require '[malli.core :as m])
(require '[malli.transform :as mt])

(def transformer
  (mt/transformer
    ;; first run schema-based transformations named :before
    {:name :before}
    ;; run json-things
    (mt/json-transformer)
    ;; add default values
    (mt/default-value-transformer)
    ;; run custom things
    {:name :after}))

(m/decoder
  [:map
   [:name string?]
   [:age int?]
   [:address
    [:map
     [:street string?]
     [:country [:enum "finland" "germany"]]]]]
  transformer)
; => clojure.core$identity

ikitommi17:02:37

I keep surprised how good the transformation engine really is.