This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-07-06
Channels
- # aws-lambda (8)
- # beginners (49)
- # boot (13)
- # braveandtrue (2)
- # cider (12)
- # cljs-dev (15)
- # cljsrn (2)
- # clojure (143)
- # clojure-italy (8)
- # clojure-nl (17)
- # clojure-spec (22)
- # clojure-uk (21)
- # clojurescript (145)
- # code-reviews (1)
- # cursive (33)
- # data-science (14)
- # datomic (25)
- # emacs (3)
- # events (1)
- # fulcro (48)
- # graphql (1)
- # onyx (15)
- # perun (5)
- # play-clj (2)
- # protorepl (1)
- # re-frame (27)
- # remote-jobs (3)
- # ring (3)
- # rum (7)
- # shadow-cljs (87)
- # specter (4)
- # test-check (14)
- # testing (2)
- # tools-deps (9)
I’d like to try and do this without custom generators… any ideas? I want to spec out a string of digits, with each having certain restrictions. e.g. each digit is (s/int-in 2 10)
but I’d like 3 in a row catted into a string. using regexes like #(re-matches #"[2-9]{3}" %)
requires me to make a custom generator I believe. Struggling with the syntax.
I can get an s/tuple
easy enough, but not sure how to jam that into a string inside the s/def
so I have
(s/def ::digit (s/int-in 2 10))
(s/def ::code (s/tuple ::digit ::digit ::digit))
but instead of a tuple/vector I want them jammed into a stringI can't answer this question, but as an aside, spec is explicitly not for parsing
why not use a regex as your spec validator, and write a custom generator?