metosin / schema-tools

Clojure(Script) tools for Plumatic Schema
http://metosin.github.io/schema-tools/
Eclipse Public License 2.0
107 stars 16 forks source link

Support set (theory) style operations #26

Open ikitommi opened 8 years ago

ikitommi commented 8 years ago

At least union, intersection, difference. Should handle optional & required keys and values and handle incompatible types gracefully.

(st/union {:id s/Str, (s/optional-key :name) s/Str, :size (s/enum :S :M)}
          {:id s/Str, :name s/Str. :size (s/maybe (s/enum :S :M))})
; {:id s/Str
;  :name s/Str
;  :size (s/enum :S :M)}

(st/union {:id s/Str} {:id s/Int})
; FAIL

(st/union {:id s/Str} {:id s/Int} s/either)
; {:id (s/either s/Str s/Int)}