Skip to content

Instantly share code, notes, and snippets.

@viebel
Forked from bhb/spec-example.clj
Last active April 27, 2017 01:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save viebel/57d9ebad3381e727c2f0a373e1bd4eec to your computer and use it in GitHub Desktop.
Save viebel/57d9ebad3381e727c2f0a373e1bd4eec to your computer and use it in GitHub Desktop.
Recursive spec with clojure.spec
(ns viebel.gist-57d9ebad3381e727c2f0a373e1bd4eec.raw.spec-example
(:require [cljs.spec :as s]))
(s/def ::tag (s/cat :type #{:div}
:attrs map?
:children (s/spec (s/* ::tag))))
(s/explain ::tag [:div {} [[:div {} []]]])
;; In: [2 0] val: [:div {} []] fails spec: _ at: [:children :type] predicate: #{:div}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment