This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-04-19
Channels
- # beginners (69)
- # boot (10)
- # cider (18)
- # cljsrn (6)
- # clojure (225)
- # clojure-austin (1)
- # clojure-dusseldorf (7)
- # clojure-france (2)
- # clojure-greece (3)
- # clojure-italy (9)
- # clojure-madison (6)
- # clojure-miami (1)
- # clojure-mke (2)
- # clojure-russia (58)
- # clojure-sg (36)
- # clojure-spec (25)
- # clojure-uk (54)
- # clojurescript (20)
- # core-async (15)
- # cursive (16)
- # datomic (71)
- # emacs (7)
- # hoplon (3)
- # jobs (5)
- # jobs-discuss (4)
- # klipse (3)
- # leiningen (2)
- # lumo (60)
- # mount (1)
- # off-topic (16)
- # om (6)
- # om-next (7)
- # onyx (21)
- # pedestal (15)
- # planck (1)
- # re-frame (3)
- # ring-swagger (4)
- # specter (33)
- # uncomplicate (31)
- # untangled (8)
- # vim (35)
Hi! I would like to add some :doc to my spec? Is there any way to do that? I need some text comments for my spec
for data, not for fn's
Not currently but maybe eventually
is there anything out there that talks about how to write custom generators for s/multi-spec?
if we write a generator that returns something sufficient for the dispatch fn to use, will the generator code know to keep generating data for the specs returned by the defmethods?
in our case, we dispatch in two different ways based on the value of :type, so we’re thinking we’d gen a map with :type with a valid value from one of the two sets of :type values we keep
Well that's where retag comes in. However I was looking at something the other day that made me question whether multi-spec was working properly in gen for non-keyword retag cases
I guess I would turn your question around and ask whether it's doing what you expect
hi. I have a map with a type key (:oic.core/rt, for resource type), whose value is a vector of type keys. how can I tell spec to form the conjunction of those types so that valid maps satisfy them all? Something like (apply s/and [::foo ::bar]), which doesn’t work.
No need. spec will automatically check all namespaced keys for which there is a spec registered
right, but different types will have different specs; for example, :oic.r/temperature requires ::p/temperature
so i need map-level validation. a map might look like
{::p/temperature 72
:oic.scale/temperature “F"
:oic.core/rt [:oic.r/temperature :oic.r/sensor oic.r/humidity]
:oic.core/if [:oic.if/baseline] }
yep, know about that, but i think that’s static - here we won’t know what to merge until runtime. at least, i’ve tried to use it but no luck so far.
i think i need something like multi-spec with the ability to dispatch multiple times
the idea is one schema for each oic.r “resource” at https://github.com/OpenInterConnect/IoTDataModels, but a resource “instance” can have multiple types - listed in :oic.core/rt
I think i have a possible solution: I use multi-spec, but my multi-methods recur over the vector of keywords. so given :oic.core/rt [::foo ::bar]
, the dispatch method will dispatch on ::foo, and the defmethod for ::foo will recur with (rest (:oic.core/rt arg))
before calling s/keys. seems to work with a simple example at least. kinda cool imho.