-
-
Save borkdude/89799a764a89af5c0be1a5745be58b4d to your computer and use it in GitHub Desktop.
Spec human errors
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
(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