This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-06-11
Channels
- # announcements (4)
- # aws (6)
- # babashka (40)
- # beginners (318)
- # biff (4)
- # bootstrapped-cljs (9)
- # calva (19)
- # chlorine-clover (1)
- # cider (3)
- # clj-on-windows (25)
- # cljdoc (8)
- # cljfx (1)
- # cljs-dev (30)
- # cljss (2)
- # clojure (62)
- # clojure-chile (9)
- # clojure-europe (11)
- # clojure-finland (17)
- # clojure-italy (1)
- # clojure-kc (1)
- # clojure-nl (3)
- # clojure-spec (27)
- # clojure-uk (40)
- # clojuremn (1)
- # clojurescript (51)
- # conjure (6)
- # cursive (8)
- # data-science (9)
- # datahike (4)
- # datascript (1)
- # datomic (31)
- # emacs (10)
- # emotion-cljs (1)
- # events (1)
- # figwheel-main (16)
- # find-my-lib (1)
- # fulcro (30)
- # graalvm (3)
- # graphql (12)
- # helix (16)
- # honeysql (5)
- # jobs (1)
- # jobs-discuss (10)
- # juxt (3)
- # kaocha (26)
- # lambdaisland (3)
- # leiningen (15)
- # malli (7)
- # off-topic (100)
- # pathom (8)
- # pedestal (15)
- # protojure (24)
- # re-frame (2)
- # reagent (7)
- # reitit (22)
- # remote-jobs (1)
- # shadow-cljs (140)
- # spacemacs (17)
- # spire (2)
- # tools-deps (23)
- # uix (11)
- # vim (5)
- # xtdb (3)
- # yada (3)
I'm struggling to wrap my head around custom transformers and validators; is there some way to create a pipeline of validate -> transform -> validate (ala spec/conform
?) Or when defining a transform interceptor, can I in some way tell the the chain to stop executing further since some assumption is invalid?
currently no way to stop the chain in interceptors @pithyless, could be added easily with reduced
. There are Schemas that short-circuit in -transform
like the :or
.
in reitit-malli
, there is a Corcion
protocol and impl which does transform + validate for requests and transform + validate + transform for responses.
for responses, it’s basically doing: 1. apply defaults, strip extra keys 2. validate the result 3. encode to whatever (string, json, xml)
^ the reitit Coercer
case is the kind of thing I have in mind. I've been going back and forth on this, but malli has been forcing me to rethink my approach: perhaps, I should just assume there is only one canonical form of data inside my project runtime, and only at the boundaries do all the encoding/decoding via custom protocols (i.e. a custom Coercer protocol and implementation for reitit, datomic, etc.)
the reitit code is here: https://github.com/metosin/reitit/blob/master/modules/reitit-malli/src/reitit/coercion/malli.cljc. Basically, at route(r) creation time, for each Schema, a reified Coercion
is created, storing encoder
, decoder
, validator
and explainer
for that schema. At runtime, it’s just a calling those (optimized fns) in whatever order suits for the use case.