This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-04-08
Channels
- # announcements (6)
- # babashka (78)
- # beginners (84)
- # bristol-clojurians (5)
- # calva (50)
- # chlorine-clover (45)
- # cider (14)
- # clj-kondo (18)
- # cljs-dev (2)
- # clojars (2)
- # clojure (387)
- # clojure-android (3)
- # clojure-europe (6)
- # clojure-gamedev (3)
- # clojure-germany (3)
- # clojure-nl (18)
- # clojure-spec (5)
- # clojure-uk (36)
- # clojurescript (8)
- # clojurex (1)
- # conjure (1)
- # css (1)
- # cursive (32)
- # data-science (1)
- # datomic (11)
- # docker (61)
- # duct (17)
- # emacs (7)
- # figwheel-main (3)
- # fulcro (19)
- # jobs-discuss (3)
- # joker (1)
- # leiningen (23)
- # malli (11)
- # mount (6)
- # off-topic (30)
- # pathom (14)
- # pedestal (2)
- # phzr (1)
- # re-frame (11)
- # reagent (3)
- # reitit (5)
- # ring-swagger (3)
- # rum (1)
- # shadow-cljs (113)
- # slack-help (9)
- # spacemacs (16)
- # specter (4)
- # sql (14)
- # vscode (2)
- # windows (3)
- # xtdb (12)
I’m not a fond of too much extra syntax for :map
. If the spec-like :or
or :and
are liked, I guess there could be :keys
schema for that?
Thanks! This does exactly what I need. One question for clarification though; When talking about too much extra syntax, do you mean :or
/ :and
or are you referring to my pull request?
I need something similar and even a bit more complex. I want to require a value either at top level or nested:
;Valid:
{:key1 "yo"}
;Also valid
{:nested {:key2 "yo"}}
It’s not the same key but they have the same meaning and one must exist.
Currently I have this schema:
[:or
[:map
[:key1 any?]
[:nested {:optional true} [:map [:key2 {:optional true} any?]]]]
[:map
[:key1 {:optional true} any?]
[:nested [:map [:key2 any?]]]]]
but I have more keys like this, and some options can be either of 3 keys so I need 3 maps for each key and then combine all of it with :and.@dcj easiest way to attach a decoder just for that enum would be:
(def Weighting
[:enum {:decode/enum weighting->kw} :dB-A :dB-C :dB-Z])
and then applying it with:
(m/decode MyMap {:weighting 0} (mt/transformer {:name :enum}))
; => {:weighting :dB-C}
if you want to have a transformer for that, you can do the same as I gisted about the :postgres/table
=> add some hint to the enum and create a transformer that attaches in :compile
just for that schema. hope this helps.