malli
malli copied to clipboard
Add `-walk` option to inherit `::val` properties
Problem: during a -walk, it's useful for the props of ::val nodes to be inherited by the :map/:or/:multi entry. Currently this is difficult to implement.
This simplifies walk-properties in the documentation, but I'm not sure it's airtight enough to release as more than a suggestion.
I considered reusing ::walk-entry-vals but it could be a breaking change.
Had to revisit how the entry walking works, this is not good:
(defn walk [schema]
(m/walk
schema
(m/schema-walker identity)
{::m/walk-entry-vals true}))
(-> [:map [:x :int]] (walk) (walk) (walk))
; [:map [:x [:malli.core/val [:malli.core/val [:malli.core/val :int]]]]]
I guess the right thing to do would be to do automatically the opposite unwrapping somewhere. Where? in the m/schema-walker?
I guess the right thing to do would be to do automatically the opposite unwrapping somewhere.
Yes, I noticed the same thing.
Where? in the m/schema-walker?
I think it would reasonable for -inner-entries to collapse any ::val schemas it finds on the way back up.
I considered reusing ::walk-entry-vals but it could be a breaking change.
I think it's a bug that the entries are kept after walking, so it would be ok to to de-walk them using ::walk-entry-vals. It's a breaking change, but for the better.