metosin / malli

High-performance data-driven data specification library for Clojure/Script.
Eclipse Public License 2.0
1.51k stars 212 forks source link

Support for prohibited keys #1110

Open SohoPak opened 1 month ago

SohoPak commented 1 month ago

Please consider adding support for prohibited keys in maps. This is similar to use = prohibited on attributes in xsd (see https://learn.microsoft.com/en-us/previous-versions/dotnet/netframework-4.0/ms256143(v=vs.100) This is useful in validation scenarios when we want to accept open maps but explicitly specify certain keys this map should not contain (e.g. :error). I am aware of the built-in :fn schema, but IMHO adding the support to the built-in :map (similar to {:closed true}) would be cleaner.

frenchy64 commented 3 weeks ago

FWIW more expressive constraints on absence of keys is planned for my Clojurists Together project.

The absence of a key will become a constraint that you can combine with and/or/implies etc.