malli
malli copied to clipboard
Check that one schema compatible with another schema
For example, there are 2 schemas:
(def person [:map
[:first-name :string]
[:last-name {:optional true} :string]
[:age :int]])
(def person-full-name [:map
[:first-name :string]
[:last-name {:optional true} :string]])
So, I'm trying to check that person-full-name is fully compatible with person schema and any value which conform person schema will be conform person-full-name schema too.
there is no built-in utility at the moment for it, but should be easy to build one, on top of the malli.util, see https://github.com/metosin/malli/issues/82.
for best effort checking, you could also:
(every? (m/validator person-full-name) (mg/sample person {:size 1000}))
; => true
PR most welcome on mu/intersection or such.