Fork me on GitHub
#malli
<
2021-07-12
>
datran05:07:18

What's the best way to update the properties of a map entry? I've got a schema like [:map [:a :string] [:b :string]], and I want to transform it into something like [:map [:a :string] [:b {:my-date :foo} :string]]. mu/update-properties only works for the :map-level, so I tried combining it with mu/update and giving a path into the map, but that also doesn't seem to be what I want. Is there a simpler way to achieve this that I'm overlooking?

ikitommi15:07:10

You can walk the children or wait for https://github.com/metosin/malli/pull/466 to be merged

ikitommi15:07:33

(defn map-children [f schema]
  (m/-into-schema (m/-parent schema) (m/-properties schema) (map f children) (m/-options schema)))

ikitommi15:07:25

that's the idiomatic way to create a copy of a schema with some changes