Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
;; see also https://twitter.com/thing_umbrella/status/1111427898487898113
(require '[clojure.spec.alpha :as s])
;; spec that ensures the keys in renames match the keys in map
(s/def ::rename-keys-args
(s/and (s/cat :map map? :renames map?)
(fn [{:keys [map renames]}]
(every? map (keys renames)))))
;; ok
(s/explain ::rename-keys-args [{:a 1} {:a 2}])
;; error
(s/explain ::rename-keys-args [{:a 1} {:b 2}])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment