malli

niwinz 2025-11-06T13:09:46.876799Z

Hey folks, a (maybe dump) question?: What is the difference betwen using [:merge map-schema-a map-schema-b] and (malli.util/merge map-schema-a map-schema-b)?

opqdonut 2025-11-06T13:11:07.517709Z

you can inspect the merge later when you use [:merge ...]

opqdonut 2025-11-06T13:11:23.704969Z

when you use malli.util/merge, it creates a new map-schema with no relation to map-schema-a and map-schema-b

opqdonut 2025-11-06T13:11:41.319369Z

for most use cases, both are fine, but if you're doing something more complicated, there might be a difference

niwinz 2025-11-06T13:11:50.914659Z

Ok, and what is a correct way to extract entries from [:merge ...] ?

opqdonut 2025-11-06T13:13:32.752619Z

user=> (def registry (merge (m/default-schemas) (mu/schemas)))
#'user/registry
user=> (m/children (m/schema [:merge [:map [:a :string]] [:map [:b :string]]] {:registry registry}))
[[:map [:a :string]] [:map [:b :string]]]

opqdonut 2025-11-06T13:14:23.548389Z

that's one way, another way might be walking the schema using malli.core/walk

niwinz 2025-11-06T13:14:41.246479Z

ok, i see, thanks for the hint