metosin / malli

High-performance data-driven data specification library for Clojure/Script.
Eclipse Public License 2.0
1.44k stars 204 forks source link

Add support for uri? in malli.transform (Clojure only) #966

Closed stig closed 8 months ago

stig commented 8 months ago

With Reitit (0.7.0-alpha7), using the below route definition, I get a failure during the coercion when passing the uri "http://example.com".

["/uri"
  {:post {:summary "Post a URI - fails coercion"
          :coercion reitit.coercion.malli/coercion
          :parameters {:body {:uri uri?}}
          :responses {200 {:body {:uri uri?}}}
          :handler (fn [{{{uri :uri} :body} :parameters}]
                     {:status 200 :body {:uri uri}})}}]]

When I replaced the :coercion with the Clojure Spec version, the coercion works.

With this change the Malli coercer should also work.

I made it Clojure specific since it relies on java.net.URI.

opqdonut commented 8 months ago

good catch re: babashka!