Skip to content

Instantly share code, notes, and snippets.

@bhb
Last active December 16, 2017 18:36
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 bhb/5abeff11f5252e915a07ea20acadd7fc to your computer and use it in GitHub Desktop.
Save bhb/5abeff11f5252e915a07ea20acadd7fc to your computer and use it in GitHub Desktop.
Expound describes missing specs
user=> (require '[clojure.spec.alpha :as s])
nil
user=> (require '[expound.alpha :as expound])
nil
user=> (s/def ::name string?)
:user/name
user=> (s/def ::age pos-int?)
:user/age
user=> (s/def ::user (s/keys :req [::name] :req-un [::age]))
:user/user
user=> (s/explain ::user {})
val: {} fails spec: :user/user predicate: (contains? % :user/name)
val: {} fails spec: :user/user predicate: (contains? % :age)
nil
user=> (expound/expound ::user {})
-- Spec failed --------------------
{}
should contain keys: `:age`, `:user/name`
| key | spec |
|------------+----------|
| :age | pos-int? |
| :user/name | string? |
-- Relevant specs -------
:user/user:
(clojure.spec.alpha/keys :req [:user/name] :req-un [:user/age])
-------------------------
Detected 1 error
nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment