This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-07-02
Channels
- # announcements (9)
- # asami (5)
- # babashka (16)
- # beginners (134)
- # chlorine-clover (3)
- # cider (15)
- # clojure (75)
- # clojure-australia (3)
- # clojure-europe (29)
- # clojure-nl (2)
- # clojure-uk (15)
- # clojured (4)
- # clojurescript (34)
- # cursive (9)
- # datomic (16)
- # duct (7)
- # events (4)
- # fulcro (2)
- # helix (5)
- # honeysql (4)
- # jobs (9)
- # lsp (55)
- # malli (31)
- # music (3)
- # re-frame (3)
- # reitit (1)
- # remote-jobs (1)
- # ring (3)
- # sci (5)
- # shadow-cljs (46)
- # specter (3)
- # tools-deps (60)
- # vim (5)
- # xtdb (15)
This is definetely something very easy to do but dont get it to work. I have a data spec as
(def email-regex #"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,63}$")
(s/def ::address (st/spec
{:spec (s/and
string?
#(re-matches email-regex %))
:reason "Must be an valid email address"
:decode/string #(str/lower-case %2 )
:swagger/type "string"
:json-schema/format "email"
:json-schema/type "string"}))
And that works just right for
(st/coerce ::address "" st/string-transformer) -> ""
But when i add that to Reitit parameter like
{:tags ["public"]
:get {:parameters {:query {:id ::address}}
:responses {200 {:body {:message string?}}}
:handler (fn [_]
{:status 200
:body {:message (-> _ :parameters :query :id)}})}}
The result is not transformed lower case.
What I am doing wrong? I have spec-coercer in coercion working because invalid falue returns an error.