This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-05-28
Channels
- # babashka (29)
- # beginners (179)
- # bristol-clojurians (1)
- # calva (9)
- # chlorine-clover (47)
- # cider (57)
- # clj-kondo (1)
- # cljs-dev (13)
- # clojure (241)
- # clojure-europe (9)
- # clojure-nl (4)
- # clojure-norway (88)
- # clojure-spec (4)
- # clojure-uk (15)
- # clojurescript (211)
- # clojutre (1)
- # community-development (8)
- # core-async (1)
- # datomic (31)
- # figwheel-main (33)
- # fulcro (29)
- # ghostwheel (6)
- # graalvm (11)
- # graphql (12)
- # instaparse (4)
- # jobs (1)
- # jobs-discuss (17)
- # leiningen (7)
- # malli (6)
- # meander (38)
- # off-topic (208)
- # onyx (6)
- # re-frame (23)
- # reagent (8)
- # shadow-cljs (61)
- # spacemacs (10)
- # sql (5)
- # yada (5)
@jstuartmilne something like:
(m/accept
[:map
[:user map?]
[:profile map?]
[:nested [:map [:x [:tuple {:deleteMe true} string? string?]]]]
[:token [string? {:deleteMe true}]]]
(fn [schema children _ options]
(if-not (:deleteMe (m/properties schema))
(let [children (filterv (if (m/map-entries schema) last identity) children)]
(m/into-schema (m/name schema) (m/properties schema) children options)))))
; => [:map [:user map?] [:profile map?] [:nested :map]]
e.g. check if the schema has the property, remove if it has. if not, you have to remove the nil
childs as it’s currently not valid syntax. There are two child syntaxes: the normal and the (map)entry-one. need to handled differently.
that doesn’t drop the empty nodes, e.g. :map
without any keys is valid, same with empty :tuple
etc.
anyone interested in doing malli.xml
? something like:
(def User [:map [:users [:vector [:map [:user string?]]]]])
(m/decode User "<users><user>simo</user></users>" malli.xml/xml-transformer)
; => {:users [{:user "simo"}]}
(m/encode User {:users [{:user "simo"}]} malli.xml/xml-transformer)
; => "<users><user>simo</user></users>"
👍 8