This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-02-10
Channels
- # announcements (2)
- # babashka (15)
- # beginners (174)
- # calva (16)
- # chlorine-clover (10)
- # clara (7)
- # clj-kondo (27)
- # cljdoc (10)
- # clojars (4)
- # clojure (50)
- # clojure-europe (10)
- # clojure-gamedev (3)
- # clojure-greece (1)
- # clojure-italy (4)
- # clojure-losangeles (1)
- # clojure-nl (16)
- # clojure-sg (1)
- # clojure-spec (7)
- # clojure-uk (41)
- # clojurescript (22)
- # data-science (15)
- # datascript (38)
- # datomic (2)
- # duct (15)
- # emacs (2)
- # fulcro (110)
- # funcool (9)
- # graphql (10)
- # jackdaw (8)
- # jobs (23)
- # joker (1)
- # leiningen (15)
- # luminus (1)
- # malli (20)
- # off-topic (26)
- # pathom (5)
- # pedestal (1)
- # reitit (19)
- # shadow-cljs (78)
- # spacemacs (2)
- # sql (52)
- # tools-deps (99)
- # vim (13)
hi @ikitommi, there is any update on this pr https://github.com/metosin/reitit/pull/354 ?
Is there a way to define coercion on optional query parameters? For example I have a url of the form
and I want the page
and per-page
to be optional. Right now doing
So I ended up defining a spec
(s/def ::list-params (s/keys :opt-un [::search/page
::search/per-page]))
and then I did
:parameters {:query ::list-params}
and it worked fine đŸ™‚this would work also:
:parameters {:query {(ds/opt :page) ::search/page
(ds/opt :per-page) ::search/per-page}}
problem with too simple syntax is that it gets easily complex, when you need to name things, add optional, maybes etc.
(s/def ::order
(s/schema {:purchaser string?
:due-date inst?
:line-items (s/coll-of (s/schema {:item-id pos-int?
:quantity nat-int?})
:kind vector?
:min-count 1
:gen-max 3)}))
inlining should work too:
:parameters {:query (s/keys :opt-un [::search/page ::search/per-page]))}
I opened this PR a while ago and would like to wrap it up: https://github.com/metosin/reitit/pull/350
Where exactly do I find the relevant docs to edit? (nevermind, I might still be a bit tired for not having seen the doc folder) I've only ever passively used cljdoc
.
Also: When I run lein test
I get an exception: Wrong number of args (2) passed to: malli.util/closed-schema
- is that something I broke?
That test seems to be broken in master