This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-09-22
Channels
- # aleph (6)
- # announcements (1)
- # babashka (2)
- # beginners (51)
- # calva (14)
- # cider (1)
- # clj-kondo (15)
- # cljs-dev (2)
- # cljsrn (1)
- # clojure (9)
- # clojure-czech (2)
- # clojure-spec (5)
- # clojure-uk (45)
- # clojuredesign-podcast (2)
- # clojurescript (4)
- # clojutre (3)
- # cursive (4)
- # datomic (8)
- # duct (8)
- # jackdaw (1)
- # joker (1)
- # keechma (1)
- # off-topic (127)
- # om (1)
- # reagent (1)
- # reitit (6)
- # shadow-cljs (22)
- # testing (3)
I just realized reitit can do coercion based on the given spec. The examples I have read usually centers around simple spec coercion, e.g. integer?
will try to parse given string value to integer. So how do you actually attach a custom coercer? I'm trying to coerce a base64 string from :path-params
into a UUID using spec coercion.
Reitit is using spec-tools
to do coercion: https://github.com/metosin/spec-tools/blob/master/docs/01_coercion.md
if uuid?
doesn't work for you, you can attach a custom decode function into spec like the doc @U662GKS3F pointed.
Is the "pretty error messages" feature for developers (i.e. for reitit configuration errors) or for users (i.e. invalid parameters sent in a request, or an exception in the handler)? https://github.com/metosin/reitit/blob/master/doc/basics/error_messages.md
@aaron51 pretty errors are for developers, all that ansi-printing is not very fast. You can intercept the paremeter errors (for users) and plug in something there too. Here’s example how to use expound with spec messages: https://cljdoc.org/d/metosin/reitit/0.3.9/doc/ring/pluggable-coercion#pretty-printing-spec-errors