This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-01-27
Channels
- # aws-lambda (3)
- # beginners (3)
- # boot (327)
- # capetown (2)
- # cider (156)
- # cljs-dev (368)
- # cljsjs (13)
- # cljsrn (53)
- # clojure (403)
- # clojure-czech (5)
- # clojure-dev (4)
- # clojure-greece (2)
- # clojure-russia (72)
- # clojure-spec (12)
- # clojure-uk (129)
- # clojurescript (156)
- # core-async (1)
- # cursive (33)
- # datomic (35)
- # emacs (10)
- # events (1)
- # hoplon (4)
- # jobs-discuss (3)
- # klipse (1)
- # lein-figwheel (14)
- # leiningen (5)
- # luminus (5)
- # off-topic (15)
- # om (69)
- # om-next (2)
- # onyx (2)
- # parinfer (15)
- # perun (12)
- # re-frame (30)
- # reagent (7)
- # ring-swagger (8)
- # spacemacs (10)
- # specter (6)
- # untangled (69)
- # yada (13)
could someone point me to some real world examples of conform? I have a hunch that it would be very useful for me, especially with specs like s/or
, but I haven’t found the output to be especially easy to adapt, for example in a cond
statement.
here’s an example that I think is overly verbose: https://gist.github.com/yayitswei/fc60da9271452716ae2a197c945a4b3e, would appreciate any tips on trimming this down
is there some existing function that gives me the same value that the predicates/specs in :fn
receive?
Hey, what are uses for the :opts
key spec on maps? As additional keys are allowed anyways and all present keys are being validated even if they are not in the explicit spec there does not seem to be any relevance for validation. Is it for generation? Something else I’m missing?
The guide says this: “ When conformance is checked on a map, it does two things - checking that the required attributes are included, and checking that every registered key has a conforming value. We’ll see later where optional attributes can be useful. Also note that ALL attributes are checked via keys, not just those listed in the :req and :opt keys. Thus a bare (s/keys) is valid and will check all attributes of a map without checking which keys are required or optional.” I do not know what “We’ll see later where optional attributes can be useful” is referring to
They are used in generators (as well as serving as doc)
@luxbock the :fn spec receives a map {:args …, :ret …}
where the values are the conformed values of the args and ret specs. you don’t need that get-fspec-attr - you can call (s/get-spec sym)
to get the fspec and that supports ILookup, so you can (:args (s/get-spec sym))
to get (for example) the args spec.
@alexmiller: thanks, yeah figured there might have been a better way