This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-12-20
Channels
- # adventofcode (47)
- # announcements (3)
- # aws (29)
- # bangalore-clj (3)
- # beginners (63)
- # boot (2)
- # braveandtrue (40)
- # calva (34)
- # cider (37)
- # cljs-dev (8)
- # clojars (3)
- # clojure (45)
- # clojure-europe (2)
- # clojure-france (4)
- # clojure-india (2)
- # clojure-italy (44)
- # clojure-japan (4)
- # clojure-nl (39)
- # clojure-serbia (1)
- # clojure-spec (21)
- # clojure-uk (75)
- # clojurescript (28)
- # cursive (24)
- # data-science (3)
- # datomic (31)
- # emacs (13)
- # fulcro (35)
- # hoplon (21)
- # jobs-discuss (66)
- # nrepl (18)
- # off-topic (72)
- # pathom (35)
- # re-frame (20)
- # reagent (54)
- # shadow-cljs (35)
- # spacemacs (9)
- # specter (8)
- # sql (13)
- # testing (9)
- # tools-deps (21)
- # vim (3)
Will there be a way to s/select
into a subset of dispatch keys of a s/multispec
?
Say I have a polymorphic map called ::payment-info
which is polymorphic, like this: (s/def ::payment-info (s/multi-spec pi ::type))
where (s/def ::type #{::credit-card ::debit-card ::net-banking ::bitcoin})
Because cards are processed one way, and each of the other types another way,
is s/select
ing into ::credit-card
and ::debit-card
a good idea?
Was just wondering about this, s/select
isn't even a thing yet so these are potential future questions 🙂
How would I write a spec to say- in this map I expect to have X Y and Z keys (which have their own specs) and then I don’t care about the rest of the map? Does specifying those 3 in the :req of the keys function assume that I don’t care about the rest?
Okay cool, thanks
So I have these 3 specs here… I am trying to say, hey there is going to be any number of inputs here in this input-type. But apparently something like {:inputs [:email {:value nil}]}
doesn’t meet this spec? It’s saying it should satisfy map?
but it seems to me that that IS a map. Anyone have a clue what I’m doing wrong here?
::inputs
is expecting a collection of ::input-type
s which are maps/`s/keys` specs, but your input is a single map
ohhh I see. thank you
you may have some other issues judging from the vector [:email {:value nil}]
, with the spec as it is
Right… yeah I may be doing some things in not the best way 🙂 time to re-evaluate
feel free to post some other sample inputs in here and I could help write some sample specs for them
I want something like:
(s/def :folder/type #{"folder" "file"})
(s/def :folder/id (s/and string? (partial re-matches #"\d*") #(< 8 (count %))))
(s/def :folder/name string?)
(s/def ::entries
(s/coll-of ::folder))
(s/def ::folder
(s/keys :req-un [:folder/type :folder/name ::entries]))
but obviously that doesn’t work(binding [clojure.spec.alpha/*recursion-limit* 2]
(gen/sample (s/gen ::folder)))
...
{:type "file",
:name "8y4FOn",
:entries ({:type "folder",
:name "",
:entries ({:type "folder", :name "x2RcQC", :entries []}
{:type "folder", :name "6on7", :entries []}
{:type "folder", :name "", :entries []}
{:type "folder", :name "aakQc3q", :entries []}
{:type "folder", :name "6g4748z", :entries []})}
{:type "file",
:name "1f",
:entries ({:type "folder", :name "j52GS", :entries []} {:type "folder", :name "e223Z", :entries []})}
{:type "file",
:name "DUuXT6",
:entries ({:type "folder", :name "t", :entries []}
{:type "folder", :name "720S2cy", :entries []}
{:type "file", :name "", :entries []}
{:type "folder", :name "", :entries []})}
{:type "folder",
:name "18EZK",
:entries ({:type "folder", :name "27", :entries []} {:type "file", :name "Q", :entries []})}
{:type "file",
:name "2K8w",
:entries ({:type "folder", :name "Pv", :entries []} {:type "file", :name "xl4346Q", :entries []})}
{:type "folder",
:name "j",
:entries ({:type "file", :name "21C", :entries []}
{:type "file", :name "3", :entries []}
{:type "folder", :name "2", :entries []}
{:type "folder", :name "1dFvly", :entries []}
{:type "folder", :name "zczGQf", :entries []})})}
...
now I wonder if there is a way to make
binding [clojure.spec.alpha/*recursion-limit* 2]
part of (s/with-gen
?now I wonder if there is a way to make
binding [clojure.spec.alpha/*recursion-limit* 2]
part of (s/with-gen
?