Skip to content

Instantly share code, notes, and snippets.

@stuarthalloway
Created March 29, 2019 12:11
Show Gist options
  • Save stuarthalloway/90055020329620dd1979fb56159c5075 to your computer and use it in GitHub Desktop.
Save stuarthalloway/90055020329620dd1979fb56159c5075 to your computer and use it in GitHub Desktop.
;; 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