Fork me on GitHub
Heikki Hämäläinen07:07:57

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._%+-][email protected][a-zA-Z0-9.-]+\.[a-zA-Z]{2,63}$")

(s/def ::address (st/spec
                   {:spec (s/and
                            #(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.