This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-10-24
Channels
- # aws (2)
- # babashka (27)
- # beginners (97)
- # calva (1)
- # cherry (12)
- # cider (6)
- # clara (12)
- # clj-kondo (24)
- # clj-on-windows (4)
- # cljfx (14)
- # clojure (54)
- # clojure-australia (3)
- # clojure-europe (26)
- # clojure-nl (1)
- # clojure-norway (4)
- # clojure-uk (9)
- # clojurescript (65)
- # conjure (5)
- # cursive (7)
- # datomic (18)
- # emacs (6)
- # helix (2)
- # honeysql (1)
- # jobs (1)
- # joyride (15)
- # kaocha (2)
- # lsp (10)
- # malli (5)
- # nbb (12)
- # observability (5)
- # off-topic (5)
- # reitit (2)
- # releases (4)
- # ring (1)
- # sci (17)
- # shadow-cljs (34)
- # testing (29)
- # tools-deps (45)
- # vim (7)
- # xtdb (6)
i'm trying to figure out spec-based transforms based on spec-tools
. i've got a strict-json-transformer defined that looks like this:
(def strict-json-transformer
(st/type-transformer
st/json-transformer
st/strip-extra-keys-transformer
st/strip-extra-values-transformer))
and a spec defined like this:
(s/def ::information (st/spec {:spec (s/nilable ::app/information)
:decode/json #(or %2 "")}))
where the idea is that the frontend sometimes sends null
for a value that isn't nullable, and i'm dealing with it on the backend. when I do:
(st/decode ::information nil strict-json-transformer)
i'd expect to get a ""
, but that doesn't seem to be happening, and I'm having a hell of a time tracing the source to understand where i might be going wrong. any pointers?i figured this out by calling (st/-name strict-json-transformer)
to get the name that it identifies itself by. turns out that because type-transformer
is doing a left-to-right merge of all of the provided transformers, it calls itself a value-transformer
, and when i did decode/value-transformer
(or whatever the name was) it started working.