This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-05-04
Channels
- # announcements (1)
- # asami (61)
- # babashka (71)
- # beginners (170)
- # biff (1)
- # calva (14)
- # clj-kondo (23)
- # cljsrn (28)
- # clojars (1)
- # clojure (152)
- # clojure-australia (2)
- # clojure-europe (65)
- # clojure-nl (2)
- # clojure-spec (8)
- # clojure-sweden (3)
- # clojure-uk (45)
- # clojurescript (1)
- # css (12)
- # cursive (16)
- # datomic (9)
- # devcards (2)
- # emacs (1)
- # events (1)
- # graalvm (31)
- # honeysql (10)
- # jackdaw (2)
- # jobs (5)
- # lambdaisland (9)
- # lsp (4)
- # malli (11)
- # meander (43)
- # off-topic (6)
- # pathom (7)
- # polylith (1)
- # portal (14)
- # re-frame (7)
- # releases (1)
- # remote-jobs (1)
- # rewrite-clj (6)
- # shadow-cljs (101)
- # specter (1)
- # tools-deps (26)
- # vim (9)
- # xtdb (2)
i'm looking to write a spec that checks a list of tuples to see if there's 0 or 1 tuple that starts with some value
i have the spec that verifies and conforms that the shape is correct:
(s/def ::handler-clause (s/cat :name (s/nonconforming
(s/or :keyword keyword?
:class symbol?))
:arglist vector?
:body (s/* any?)))
and then in the fdef
i have (s/* (s/spec ::handler-clause))
for that argument
inputs look like [:error [& args] (println args)]
or [:no-error [& args] args]
?
is for 0 or 1
my apologies, i mean, i'd like to have it check that there is any number of tuples that don't start with :no-error
and 0 or 1 tuples that start with :no-error
so something like
(s/fdef handler-case
:args (s/cat :expr any?
:bindings (s/and (s/? (s/cat :name (s/and #(= :no-error %)
(s/nonconforming
(s/or :keyword keyword?
:class symbol?)))
:arglist vector?
:body (s/* any?)))
(s/* (s/cat :name (s/and #(not= :no-error %)
(s/nonconforming
(s/or :keyword keyword?
:class symbol?)))
:arglist vector?
:body (s/* any?)))
)))