Closed vemv closed 1 year ago
Mmm, https://github.com/metosin/malli/tree/4b4fe875203317eba1057bdffba6d7d8c9e78469#qualified-keys-in-a-map seemed promising, but it needs one to explicitly enumerate the keys.
IOW, reusing the scratchpad above, (m/validate [:map ::string] {::string 1})
has the behavior I want, but (m/validate [:map] {::string 1})
not.
We think that this is a design problem in spec, see e.g.
https://quanttype.net/posts/2021-03-06-clojure-spec-and-untrusted-input.html
We don't want this in malli currently, but could be convinced otherwise if there are good arguments!
https://clojure.org/guides/spec#_entity_maps says:
Probably you know this behavior, but as a recap, it means that all specs are subject to be checked in any map. Which can be nice as it maximizes the use of specs, and encourages using namespaced keys.
I wonder if Malli can replicate this behavior?
Here is a minimal scratchpad:
...it shows that the implicit key checking isn't there. Which fully makes sense for Malli's philosophy, tbh. Is this a problem someone has tackled before?
Probably overriding the definition of
:map
isn't too far-fetched - I might try that. Still, I'd be interested in alternative approaches if any are possible.Cheers - V