This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-04-28
Channels
- # aleph (3)
- # announcements (3)
- # babashka (8)
- # beginners (12)
- # biff (4)
- # calva (12)
- # clerk (29)
- # clj-kondo (1)
- # clojure (104)
- # clojure-art (1)
- # clojure-austin (5)
- # clojure-berlin (3)
- # clojure-brasil (34)
- # clojure-europe (11)
- # clojure-germany (16)
- # clojure-losangeles (9)
- # clojure-nl (30)
- # clojure-norway (58)
- # clojure-uk (1)
- # core-async (8)
- # cursive (4)
- # data-science (9)
- # datalevin (1)
- # datomic (40)
- # emacs (2)
- # events (3)
- # helix (1)
- # honeysql (3)
- # hugsql (1)
- # hyperfiddle (66)
- # jobs (4)
- # juxt (7)
- # kaocha (9)
- # lsp (5)
- # malli (10)
- # off-topic (4)
- # polylith (2)
- # reitit (5)
- # releases (1)
- # remote-jobs (5)
- # sci (46)
- # scittle (2)
- # shadow-cljs (9)
- # tools-deps (17)
- # xtdb (8)
I have a question about coercion of :or
schemas: If the value already conforms to one of the or'd schemas but it can be coerced to the first one, does it make sense to coerce it to that (as seems to be the current behavior)? Wouldn't it be better to leave it alone? Is there a way to do that? For example, I have a schema that is just [:or :keyword :string]
but it keeps coercing all of my strings to keywords even though strings are allowed too.
Should I just do a validate
check before coercing?
And actually, I'm not sure I can easily do that in this context. I'm using reitit w/ malli request coercion and I need it to leave my strings alone, but it converts them to keywords.
perhaps coercion should short-circuit if the value already validates?
probably some performance implications to all of this
Or should already short-circuit on first valid value. It has a (small) performance penalty to validate after decode, but think it's the only way to make it work
yeah, I guess it's the decode
step that's doing the string -> keyword change. I'm using the json-transformer but trying to leave strings as strings. this is not a map key. but the [:or :keyword :string]
schema seems to decode the string to a keyword. unless I'm misunderstanding...
yeah, I had thought I couldn't b/c I need EDN to stay as keywords when using that. but then I remembered that that won't activate the json-transformer in the first place. so that might be the key!