Fork me on GitHub
#malli
<
2023-03-13
>
andre22:03:15

Thoughts on making malli.util/get and malli.util/get-in schemas like merge, union and select-keys are? To avoid code duplication, I'm writing schemas like: [:map [:foo (m.u/get domain-schema ::domain-schema/foo)]], would be nice to be able to write [:map [:foo [:get domain-schema ::domain-schema/foo]]] instead.

ikitommi20:03:01

That would be handy, but you could also add the schemas to registry and just say [:map [:foo ::domain-schema/foo]]

andre15:03:48

But I'd need to manually register all the keys, right? Something like the below, where register-keys walks over the schema and adds them to registry?

(register-keys [:map [::foo any?]])

ikitommi15:03:46

Yes, something like:

(my-register! ::foo any?)
(my-register! ::bar int?)

[:map ::foo ::bar]

andre15:03:53

Looks a little error prone, as users would need to remember to register every single key, and we would also need to worry about the same key being registered twice and the last one overwriting the first one. That doesn't happen with :get/:get-in since it looks specifically for one schema. Would it be ok if I tried opening a PR for :get/:get-in as schemas? Or do you have a strong preference for the registry approach?