Skip to content

Instantly share code, notes, and snippets.

@bostonaholic
Created January 10, 2019 18:15
Show Gist options
  • Save bostonaholic/6490a1132941dca2b62b28996a3bf1ea to your computer and use it in GitHub Desktop.
Save bostonaholic/6490a1132941dca2b62b28996a3bf1ea to your computer and use it in GitHub Desktop.
conforming `s/or` clojure specs
user=> (s/def ::name string?)
:user/name
user=> (s/def ::id int?)
:user/id
user=> (s/conform ::name "bob ross")
"bob ross"
user=> (s/conform ::id 42)
42
user=> (s/def ::name-or-id (s/or ::name2 string? ::id2 int?))
:user/name-or-id
user=> (s/conform ::name-or-id "bob ross")
[:user/name2 "bob ross"]
user=> (s/conform ::name-or-id 42)
[:user/id2 42]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment