Skip to content

Instantly share code, notes, and snippets.

@viebel
Created February 1, 2017 09:07
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 viebel/6bdefe58f4a38591399f0628fb775418 to your computer and use it in GitHub Desktop.
Save viebel/6bdefe58f4a38591399f0628fb775418 to your computer and use it in GitHub Desktop.
(require '[clojure.spec :as s])
(require-macros '[gadjett.core :refer [dbg]])
;; with s/alt it is valid
(dbg (s/valid? (s/cat
:a (s/alt :p (s/cat :x string? :y string?)
:q number?)
:b string?)
["foo" "bar" "qux"]))
;; with s/or it is not valid
(dbg (s/valid? (s/cat
:a (s/or :p (s/cat :x string? :y string?)
:q number?)
:b string?)
["foo" "bar" "qux"]))
;; however, it would with a nested sequence
(dbg (s/valid? (s/cat
:a (s/or :p (s/cat :x string? :y string?)
:q number?)
:b string?)
[["foo" "bar"] "qux"]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment