Fork me on GitHub
#malli
<
2022-02-28
>
rovanion15:02:43

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   

2
rovanion16:02:34

Ah, okey, so you need to pass {::malli/walk-entry-vals true}.

Oliver Marks20:02:52

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 ?