Skip to content
Laurent Senta edited this page Sep 17, 2016 · 1 revision

Match a map for required keys and allow any other optional keys ("polymorphism")

you can use the s/Any to allow anything else in a map.

For example:

(ns my-ns
  (:require [schema.core :as s]))

(def MySchema {:required s/Keyword
               s/Any     s/Any})

(s/check MySchema {:required :a} ;; => nil
(s/check MySchema {:other :x}) ;; => {:required missing-required-key, :other disallowed-key}
(s/check MySchema {:other :x :required :a}) ;; => nil