Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@borkdude
Last active March 21, 2018 11:48
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 borkdude/89799a764a89af5c0be1a5745be58b4d to your computer and use it in GitHub Desktop.
Save borkdude/89799a764a89af5c0be1a5745be58b4d to your computer and use it in GitHub Desktop.
Spec human errors
(s/fdef my-component
:args
(s/cat :opts
(s/and
(s/keys
:opt-un [::collapsed?
::collapsible?])
(fn
;; "Use either :collapsed or :collapsible?, but not both. This doesn't make sense."
[m]
(not (and (:collapsed m)
(:collapsible? m)))))))
;; vs.
(s/fdef my-component
:args
(s/cat :opts
(s/and
(s/keys
:opt-un [::collapsed?
::collapsible?])
(s/with-human-error
(fn [m]
;; these options are mutually exclusive
(not (and (:collapsed? m)
(:collapsible? m))))
(fn [_]
"Use either :collapsed or :collapsible?, but not both. This doesn't make sense.")))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment