Last active
July 15, 2016 09:29
-
-
Save st/ff105f4da5bc47e76fece033aad23b22 to your computer and use it in GitHub Desktop.
first steps with clojure.spec
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
user=> (require '[clojure.spec :as s]) | |
nil | |
user=> (s/def ::big #(< 10 %)) | |
:user/big | |
user=> (s/valid? ::big 10) | |
false | |
user=> (s/valid? ::big 100) | |
true | |
user=> (s/def ::big-or-even (s/or ::big even?)) | |
:user/big-or-even | |
user=> (s/valid? ::big-or-even 100) | |
true | |
user=> (s/valid? ::big-or-even 101) | |
false | |
;; why ? | |
user=> (s/explain ::big-or-even 101) | |
val: 101 fails spec: :user/big-or-even at: [:user/big] predicate: even? | |
;; why o why ? |
Author
st
commented
Jul 15, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment