This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-07-16
Channels
- # aleph (2)
- # announcements (1)
- # beginners (162)
- # calva (16)
- # cider (37)
- # cljdoc (9)
- # cljs-dev (2)
- # cljsrn (3)
- # clojure (86)
- # clojure-dev (17)
- # clojure-europe (3)
- # clojure-houston (1)
- # clojure-italy (6)
- # clojure-nl (3)
- # clojure-spec (10)
- # clojure-uk (20)
- # clojuredesign-podcast (15)
- # clojurescript (7)
- # data-science (14)
- # datascript (1)
- # datomic (5)
- # emacs (8)
- # figwheel-main (8)
- # fulcro (25)
- # graalvm (1)
- # jobs (10)
- # jobs-discuss (4)
- # keechma (14)
- # leiningen (2)
- # off-topic (31)
- # onyx (1)
- # other-languages (4)
- # pathom (4)
- # pedestal (1)
- # re-frame (20)
- # remote-jobs (4)
- # shadow-cljs (25)
- # sql (6)
- # tools-deps (15)
- # vim (18)
- # xtdb (9)
Hi, I’m trying to figure out how to model this with spec.
Say I have (s/def ::rule-type #{:rule1 :rule2})
I then want to create (s/def ::rule1 (s/keys ...)
, etc where aside from the keys that are selected ::rule-type is ‘narrowed’ to specific value, such that I can then have a ::rule spec that’s an or of those guys
might be what multi-spec is for?
yes, seems like exactly what s/multi-spec is for
ah ok, actually just got it working with and s/and ‘passthru’ but will try the mult-spec as well
did this
(s/and (s/keys :req [::rule-type ::rule-id ::rule-action ::object-locator]
:opt [::load-order])
#(= (::rule-type %) :selection)))
but yeah multi-spec seems a bit more elegant
spec2 looks exciting @alexmillerIt also gives much better feedback (more specific) when using with expound for instance
s/multi-spec is also open so you can add more rules later
not something we're working on right now, but maybe eventually