This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-01-31
Channels
- # announcements (1)
- # aws (4)
- # babashka (40)
- # beginners (89)
- # calva (13)
- # cider (3)
- # clj-kondo (36)
- # cljdoc (16)
- # clojure (74)
- # clojure-boston (1)
- # clojure-dev (7)
- # clojure-europe (30)
- # clojure-new-zealand (1)
- # clojure-nl (17)
- # clojure-uk (5)
- # clojurescript (16)
- # core-async (9)
- # cursive (16)
- # datahike (3)
- # datalog (6)
- # datascript (7)
- # datomic (15)
- # emacs (38)
- # events (2)
- # figwheel-main (3)
- # fulcro (6)
- # google-cloud (18)
- # graalvm (6)
- # gratitude (1)
- # honeysql (1)
- # introduce-yourself (1)
- # jobs (1)
- # leiningen (5)
- # lsp (6)
- # malli (11)
- # meander (2)
- # off-topic (4)
- # re-frame (6)
- # reitit (8)
- # releases (2)
- # remote-jobs (3)
- # reveal (4)
- # shadow-cljs (200)
- # sql (8)
- # tools-deps (16)
when inferring malli schemas from data, I can tell it how to handle strings as uuids, for example, as shown here https://github.com/metosin/malli/pull/597 some string values may be inst or other types - is there a way to have it handle those as well?
sure, anything you can present transformers works here. Check how inst?
is handled in malli.transform
sorry, I should have given a better example
(require '[malli.provider :as mp])
(require '[malli.transform :as mt])
(mp/provide
[{:my-uuid "caa71a26-5fe1-11ec-bf63-0242ac130002"
:my-inst "2021-01-01T00:00:00Z"}]
{::mp/value-decoders {'string? {:uuid mt/-string->uuid}}})
;; can I treat :my-uuid as a uuid and :my-inst as an inst?
with master:
(require '[malli.provider :as mp])
(require '[malli.transform :as mt])
(mp/provide
[{:my-uuid "caa71a26-5fe1-11ec-bf63-0242ac130002"
:my-inst "2021-01-01T00:00:00Z"}]
{::mp/value-decoders {'string? {:uuid mt/-string->uuid
'inst? mt/-string->date}}})
; => [:map [:my-uuid :uuid] [:my-inst inst?]]
thank you!
so this would be after 0.8.0
if you use deps, you can depend on the lastest commit on master to try this out. for leiningen - in the next release.
we're using some custom bazel thing, so I'll have to wait for the jar. thank you so much for this feature! type providers were so awesome in F# - I really appreciate having something similar in Clojure!
with master:
(require '[malli.provider :as mp])
(require '[malli.transform :as mt])
(mp/provide
[{:my-uuid "caa71a26-5fe1-11ec-bf63-0242ac130002"
:my-inst "2021-01-01T00:00:00Z"}]
{::mp/value-decoders {'string? {:uuid mt/-string->uuid
'inst? mt/-string->date}}})
; => [:map [:my-uuid :uuid] [:my-inst inst?]]