Created
May 26, 2017 01:43
-
-
Save puredanger/4ca8fd95bcdee0601f09410b4b2f85c2 to your computer and use it in GitHub Desktop.
Staged spec validation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; for the use case where same key is transformed through stage | |
(s/def :st1/a int?) | |
(s/def :st2/a string?) | |
(defn validate-map [stage m] | |
(every? (fn [[k v]] (s/valid? (keyword stage (name k)) v)) m)) | |
(validate-map "st1" {:a 100}) ;; true | |
(validate-map "st2" {:a "abc"}) ;; true | |
(validate-map "st1" {:a "abc"}) ;; false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment