This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-07-15
Channels
- # announcements (3)
- # aws (2)
- # babashka (57)
- # beginners (24)
- # clj-kondo (5)
- # clj-together (3)
- # cljs-dev (11)
- # clojure (83)
- # clojure-australia (1)
- # clojure-china (1)
- # clojure-europe (32)
- # clojure-filipino (1)
- # clojure-hk (5)
- # clojure-indonesia (1)
- # clojure-japan (1)
- # clojure-korea (1)
- # clojure-my (1)
- # clojure-nl (1)
- # clojure-norway (1)
- # clojure-sg (1)
- # clojure-spain (1)
- # clojure-taiwan (1)
- # clojure-uk (2)
- # clojurescript (7)
- # conjure (36)
- # data-science (19)
- # datomic (27)
- # emacs (44)
- # events (4)
- # fulcro (16)
- # honeysql (6)
- # inf-clojure (1)
- # interop (5)
- # malli (5)
- # nbb (1)
- # off-topic (19)
- # pathom (4)
- # practicalli (1)
- # remote-jobs (4)
- # ring (1)
- # shadow-cljs (72)
- # spacemacs (2)
Is there a built-in way in Malli to strip away map keys that are not in the schema? Let’s say I have an open map schema like this:
[:map [:person/first-name string?]
[:person/last-name string?]]
And a compliant value with an extra key:
{:person/first-name "Cosmo"
:person/last-name "Kramer"
:person/likes #{:fruit}}
I’d like to “sanitise” this data and only keep specified keys, recursively.Thanks for acting as a sound stage. I found a simple way that can easily extended for recursive application:
(require '[malli.util :as mu])
(select-keys data (mu/keys schema))
There's a built-in strip-extra-keys-transformer
for value transformation https://github.com/metosin/malli#value-transformation
✨ 1
Amazing, thanks! Missed that one 😊