Fork me on GitHub
#malli
<
2023-03-14
>
cap10morgan22:03:34

is it possible to define a schema for semi-homogenous maps? I have a map with a specific (optional) key that needs to point at one schema for its value (when present) but then every other key in the map is of a different type whose values are all of yet another type. to make things extra fun, I need that optional key to go through a custom decoder fn. so the specific key's schema looks like:

[:and
 [:map-of ::at-context :any] ; for ::at-context's decode fn
 [:map ["@context" {:optional true} ::context]]]
and the schema for the other k-v's in the map is:
[:map-of ::iri ::val]
but I have not found a way to combine those so that a map of mostly {::iri ::val} can have an optional {"@context" ::context} in it.