This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-02-28
Channels
- # announcements (14)
- # autochrome-github (1)
- # babashka (4)
- # beginners (151)
- # biff (1)
- # calva (24)
- # cider (13)
- # clara (13)
- # clj-commons (1)
- # cljs-dev (24)
- # clojure (50)
- # clojure-europe (20)
- # clojure-france (13)
- # clojure-nl (4)
- # clojure-norway (12)
- # clojure-spec (43)
- # clojure-uk (6)
- # clojurescript (30)
- # cursive (2)
- # datahike (9)
- # editors (6)
- # emacs (2)
- # fulcro (29)
- # google-cloud (20)
- # graphql (2)
- # humbleui (2)
- # jobs (2)
- # juxt (4)
- # kaocha (5)
- # lsp (14)
- # malli (5)
- # membrane (10)
- # off-topic (39)
- # pathom (21)
- # polylith (10)
- # rdf (8)
- # reagent (4)
- # remote-jobs (3)
- # reveal (18)
- # shadow-cljs (27)
- # spacemacs (7)
- # tools-deps (30)
Given a Malli map schema like [:map [:key {:optional true} :int]]
, how do I get at the properties assigned the keyword :key
in the map when writing a walker? In this example, these are {:optional true}
.
As you can see in the below example the walker visits all the "values" of the map, in this case just the :int
schema, and then out to the :map
schema. Is there any way to get to the inbetween step, the "schema" and properties of :key
?
(malli/walk
[:map [:key {:optional true} :int]]
(fn [schema path children options]
(println "Schema:" schema)
(println "Path:" path)
(println "Children:" children)
(println "Options:" options)
(println "Properties:" (malli/properties schema))
(println))) => nil
;; Schema: :int
;; Path: [:key]
;; Children: nil
;; Options: nil
;; Properties: nil
;;
;; Schema: [:map [:key {:optional true} :int]]
;; Path: []
;; Children: [[:key {:optional true} nil]]
;; Options: nil
;; Properties: nil
Would this help? https://cljdoc.org/d/metosin/malli/0.8.3/doc/tips#walking-schema-and-entry-properties
So setup a test case from the example project, https://github.com/olymk2/reitit/commit/6fd0ee5b6d1553cfc25227836b8a3a126b77b5d5 I have added a single param to the malli spec if you just submit the defaults it sends "january" and errors because its not a key my understanding is this should be decoded by the transformer ? is this a bug or something I am not understanding ?