This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-07-25
Channels
- # announcements (22)
- # architecture (6)
- # beginners (76)
- # cider (44)
- # clara (6)
- # clj-kondo (34)
- # cljdoc (4)
- # cljs-dev (8)
- # clojure (162)
- # clojure-brasil (4)
- # clojure-dev (32)
- # clojure-europe (3)
- # clojure-italy (16)
- # clojure-japan (4)
- # clojure-nl (3)
- # clojure-poland (1)
- # clojure-spec (25)
- # clojure-uk (45)
- # clojuredesign-podcast (5)
- # clojurescript (91)
- # clojutre (3)
- # core-async (19)
- # core-logic (8)
- # cursive (60)
- # data-science (3)
- # datomic (7)
- # defnpodcast (2)
- # duct (5)
- # emacs (7)
- # fulcro (1)
- # graalvm (9)
- # graphql (1)
- # jackdaw (12)
- # jobs (1)
- # jobs-discuss (1)
- # kaocha (3)
- # leiningen (3)
- # luminus (2)
- # off-topic (44)
- # onyx (17)
- # pathom (6)
- # planck (15)
- # re-frame (1)
- # reagent (13)
- # rum (2)
- # shadow-cljs (43)
- # spacemacs (3)
- # sql (43)
- # tools-deps (3)
- # vim (43)
- # xtdb (13)
is there an example out there of a spec on arguments that look like
([a])
([a b])
([a b c])
([a b c d])
([a b c d e])
where later arguments are optional and can be omitted and replaced with defaults? I feel like there has to be a better way than just a big s/alt
with a bunch of s/cat
s but I can't think of it right now(s/cat :a ::a (s/? :b ::b (s/? :c ::c (s/? :d ::d (s/? :e ::e)))))
but also, sometimes s/alt
is clearer, just depends
I didn't realize you could cascade s/?
like that... I've only seen (s/cat :a ::a :b (s/? ::b))
before I think?
Hmm, according to the docs/source, s/?
can only take a single pred-form
@alexmiller
how to write spec that conforms input value to positive int or to zero when value missing?
like that
(s/def ::offset
(s/or
:nil (s/and nil? (s/conformer (constantly 0)))
:int (s/and int? #(<= 0 %))))
@seancorfield sorry, tired
should be s/cats in there
@maxp imo, you should not do that with specs
s/or always conforms to a tagged result where the tag matches the branch that was taken
but general data transformation is best applied outside spec, not as part of conforming anyways
is it possible to "attach" some human readable message to the spec to get it in (explain-data) ?
Is there a way to get the resolved value for a given spec? I have a set I generate as a spec and I'm wondering if there's a way to access that set from the spec api:
(s/def ::sec-type (set (map str (Types$SecType/values))))
(s/describe ::sec-type) ;;=> (set (map str (values))) ;can't eval this
@jjttjj Try s/form
instead.
s/describe
returns an "abbreviated" version.
hey, can anybody help me with it? https://clojurians.slack.com/archives/C1B1BB2Q3/p1563950441028500