Skip to content

Instantly share code, notes, and snippets.

@MichaelDrogalis
Last active May 25, 2016 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MichaelDrogalis/016ac62cf3f1e899fb89fd79f2de2277 to your computer and use it in GitHub Desktop.
Save MichaelDrogalis/016ac62cf3f1e899fb89fd79f2de2277 to your computer and use it in GitHub Desktop.
(s/def ::a integer?)
(s/def ::b string?)
(clojure.pprint/pprint (s/explain-data (s/keys :req [::a ::b]) {::a "foo" ::b "bar"}))
;; =>
;; {:clojure.spec/problems
;; {[:empathy.api/a]
;; {:pred integer?,
;; :val "foo",
;; :via [:empathy.api/a],
;; :in [:empathy.api/a]}}}
(clojure.pprint/pprint (s/explain-data (s/keys :req [::a ::b]) {}))
;; =>
;; {:clojure.spec/problems
;; {[]
;; {:pred [(contains? % :empathy.api/a) (contains? % :empathy.api/b)],
;; :val {},
;; :via [],
;; :in []}}}
(clojure.pprint/pprint (s/explain-data (s/tuple ::a) []))
;; =>
;; {:clojure.spec/problems
;; {[]
;; {:pred (clojure.core/= (clojure.core/count %) 1),
;; :val [],
;; :via [],
;; :in []}}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment