This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-12-13
Channels
- # adventofcode (37)
- # announcements (11)
- # babashka (46)
- # beginners (35)
- # biff (1)
- # clojure (44)
- # clojure-austin (1)
- # clojure-europe (23)
- # clojure-nl (2)
- # clojure-norway (8)
- # clojure-uk (5)
- # conjure (3)
- # cursive (22)
- # data-science (13)
- # docker (11)
- # events (8)
- # hyperfiddle (7)
- # joyride (1)
- # juxt (9)
- # malli (7)
- # matrix (4)
- # pedestal (3)
- # podcasts-discuss (1)
- # portal (1)
- # re-frame (62)
- # reitit (2)
- # releases (1)
- # schema (3)
- # sql (14)
- # squint (3)
- # xtdb (6)
- # yamlscript (4)
How do you express how schemas evolve?
For example, I validate the input to guarantee-language
with this schema:
;;input to guarantee-language
[:map
[:language {optional true} :string]
[...]]
For the output schema, I would like to say it's the input schema of guarantee-lang
but [:language {optional true} :string]
is replaced with [:language :string]
.
Since it's just vector I could do this myself in a presumably ugly way, but I wanted to know if there's a standard way to do it.You can use malli.util/required-keys (mu/required-keys guarantee-language [:language])
I wrote malli-select (linked in Malli’s README) to allow for selection of required map-attributes. It handles maybe’s/collections etc. supports pruning (of optionals) and raises when you try to select an unknown path.
@U04V6FEES I tried out the deps-try thing (pretty cool), and use malli a lot. are you getting much use out of malli-select in practice?
@U051GFP2V thanks. Yeah, for a pet-project I have a video-entity that starts out as just a youtube-id and gets extended in several steps (title, duration, playable?, seconds played, completed? etc.). Having one schema that shows the total picture of a video and then being able to quickly create subset-schemas for processes that do small updates is very helpful.
Also generating test-data is a breeze this way, especially with a little glue-code that injects the :gen/*
properties: https://twitter.com/DontBeEval/status/1703024976947744980