Open dspiteself opened 1 year ago
you can use vector to set the properties with mu/assoc
:
(mu/assoc [:map [:x :int] [:y :int]] [:z {:optional true}] :int)
; => [:map [:x :int] [:y :int] [:z {:optional true} :int]]
thanks
Would it be possible to make it work with a function?
(mu/assoc [:map [:x :int] [:y :int]] [:z (fn [props] (assoc props :optional true)) :int)
; => [:map [:x :int] [:y :int] [:z {:optional true} :int]]
If you are interested I could make a pull request to detect a function and apply instead of overwrite. https://github.com/metosin/malli/blob/8ef1f98e8dda3e94eaefe87d4cb3b3f47c36faec/src/malli/core.cljc#L397
Our company generates a lot of spec from data definitions We us
[malli.util :as mu]
to update those specs with vendor specific information. Currently we have to usemu/transform-entries
when we want to changeMapEntry
properties. It would be much more straight forward to our new users is they could usemu/assoc
with another argument to set the the properties. I do not know how we could enhancemu/update
to be able to update properties maybe using:malli.core/value
but that would be breaking. We are getting by withmu/transform-entries
but any feedback would be nice. We would be willing to make a patch.