metosin / malli

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

Set Operations with (Map) Schemas #82

Open ikitommi opened 4 years ago

ikitommi commented 4 years ago

Currently, we have m/merge. Instead, we should have malli.set with at least:

should these also work with values? e.g:

(require '[malli.set :as ms])

(ms/difference [:map [:x int?] [:y int?]] {:x 1})
; => [:map [:y int?]]
esuomi commented 4 years ago

Thinking out loud, while having them work with values in the way you show could be used for producing better error messages, malli already handles that part really well so it'd be overlapping functionality.

There also might be cases where it's somewhat ambiguous whether the second value is a schema or an actual value, as the projects I work with tend to have lookup maps from keywords to functions to enable certain dynamic behaviors, especially on frontend side. So maybe having it work with values would be a bit superfluous?

ikitommi commented 4 years ago

There is now separete malli.util/merge and malli.util/union.