This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-06-07
Channels
- # announcements (13)
- # atom-editor (3)
- # babashka (53)
- # beginners (28)
- # clojure (30)
- # clojure-australia (4)
- # clojure-europe (22)
- # clojure-germany (1)
- # clojure-italy (6)
- # clojure-nl (3)
- # clojure-norway (14)
- # clojure-spec (8)
- # clojure-uk (8)
- # clojurescript (19)
- # cursive (33)
- # datomic (4)
- # defnpodcast (6)
- # events (3)
- # fulcro (3)
- # graalvm (77)
- # jobs (2)
- # juxt (11)
- # podcasts-discuss (1)
- # reitit (1)
- # releases (2)
- # remote-jobs (2)
- # sci (1)
- # shadow-cljs (27)
- # sql (6)
- # testing (10)
- # tools-deps (36)
- # vim (4)
- # xtdb (15)
Using Malli for coercion. How do I set up a (query) param for a list of values conforming to a regex?
(def id-regex #"^[A-Za-z\d\-_]{10}$")
(def routes
["" {:coercion reitit.coercion.malli/coercion}
["/some-path"
{:get {:handler some-handler-fn
:parameters {:query
[:map
[:some-arg
[:sequential
[:re id-regex]]]]}}}]])
The endpoint shows up in Swagger docs, but when I test it with one or more values, the endpoint throws me errors.
{
"schema": "[:map {:closed true} [:some-arg [:sequential [:re #\"^[A-Za-z\\d\\-_]{10}$\"]]]]",
"errors": [
{
"in": [
"some-arg"
],
"path": [
"some-arg"
],
"message": "invalid type",
"type": "malli.core/invalid-type",
"schema": "[:sequential [:re #\"^[A-Za-z\\d\\-_]{10}$\"]]",
"value": "1234567890,1234567891"
}
],
"value": {
"some-arg": "1234567890,1234567891"
},
"type": "reitit.coercion/request-coercion",
"coercion": "malli",
"in": [
"request",
"query-params"
],
"humanized": {
"some-arg": [
"invalid type"
]
}
}
Looks like it's processing the query parameter as just a string instead of a sequence of strings.