Fork me on GitHub
#malli
<
2024-03-09
>
Pavel Mugyrin20:03:05

Hi everyone! Is it possible to make transformations work in a depth-first fashion? Here is the example:

(def TimestampAndMap
    [:map {:encode/edn pr-str
           :decode/edn clojure.edn/read-string}
     [:timestamp [:time/instant {:encode/timestamp #(.getEpochSecond %)
                                 :decode/timestamp #(Instant/ofEpochSecond %)}]]])

 => (m/encode TimestampAndMap {:timestamp (Instant/now)} (mt/transformer {:name :timestamp} {:name :edn}))
"{:timestamp #object[java.time.Instant 0x8e217f2 \"2024-03-09T20:15:38.302046177Z\"]}"

;; but i would rather want to see
"{:timestamp 1710015535}"