This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-08-23
Channels
- # babashka (4)
- # beginners (46)
- # biff (64)
- # calva (34)
- # cider (29)
- # cljdoc (12)
- # cljs-dev (16)
- # clojure (42)
- # clojure-australia (2)
- # clojure-china (1)
- # clojure-europe (35)
- # clojure-filipino (1)
- # clojure-hk (1)
- # clojure-indonesia (1)
- # clojure-japan (1)
- # clojure-korea (1)
- # clojure-my (1)
- # clojure-nl (1)
- # clojure-norway (6)
- # clojure-sg (1)
- # clojure-taiwan (1)
- # clojure-uk (4)
- # clojurescript (3)
- # core-typed (3)
- # cursive (5)
- # datalevin (3)
- # datomic (23)
- # hyperfiddle (92)
- # joyride (8)
- # juxt (3)
- # malli (1)
- # nbb (44)
- # pathom (10)
- # portal (3)
- # rdf (1)
- # reitit (10)
- # shadow-cljs (60)
- # sql (12)
I'm trying to write a schema for a map where a few keys are optional. These are coming in through a form post through ring/reitit and coercion is working well. I can get it so that it converts empty strings to nil
but I think it'd be nice to dissoc
it from the map entirely. I have something like this so far:
(defn omit-blank [s]
(when-not (str/blank? s)
s))
(def user (m/schema [:map {:closed true}
[:user/email :string]
[:user/alias {:decode/string omit-blank
:optional true} [:maybe :string]]]))
I found a similar post here, but I'm not sure where to put the function that was mentioned as a solution:
https://clojurians.slack.com/archives/CLDK6MFMK/p1653309841392379