This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-09-01
Channels
- # announcements (10)
- # aws (1)
- # babashka (19)
- # beginners (104)
- # calva (50)
- # cider (17)
- # cljs-dev (135)
- # cljsrn (56)
- # clojure (240)
- # clojure-dev (4)
- # clojure-europe (19)
- # clojure-nl (2)
- # clojure-uk (7)
- # clojurescript (22)
- # conjure (2)
- # css (1)
- # cursive (10)
- # data-science (1)
- # datomic (60)
- # emacs (2)
- # events (2)
- # exercism (1)
- # figwheel-main (3)
- # fulcro (13)
- # graalvm (5)
- # gratitude (1)
- # inf-clojure (4)
- # introduce-yourself (5)
- # jobs-discuss (21)
- # lsp (36)
- # malli (6)
- # meander (8)
- # missionary (12)
- # off-topic (14)
- # pathom (13)
- # pedestal (10)
- # polylith (42)
- # re-frame (5)
- # reagent (12)
- # reitit (3)
- # releases (8)
- # sci (10)
- # shadow-cljs (37)
- # sql (5)
- # tools-deps (6)
Is there a way to customize the “missing required key” error message? For example, the code below returns the default missing key error message instead of something's wrong
which makes sense because :error/message
relates to the contents of :something
, not to whether the key is present. It would be great if we could customize missing key errors.
(me/humanize (m/explain
[:map
[:something
[:string {:error/message "something's wrong"}]]]
{}))
Have you tried putting it on the entry's props?
as in:
[:something {:error/message "something's wrong"} :string]
@U06GVE6NR Yes, the result is the same.
What's the best way to specify a schema for a map with both fixed keys and dynamic keys? Conceptually what I'd like is something like this schema to specify that a step has a :run
keyword and some dynamic keys, and a workflow has :name
and :start
keywords and some dynamic keys:
(def step
[:and [:map [:run :qualified-keyword]]
[:map-of :keyword [:map [:next :keyword]]]])
(def workflow
[:and [:map [:name :string]
[:start :keyword]]
[:map-of :keyword step]])
The data has this shape:
{:name "my-workflow"
:start :begin
:begin
{:run :app/init
:ok {:next :do-work}
:fail {:next :done}}
:do-work
{:run :app/process-queue
:ok {:next :done}}
:done
{:run :app/cleanup}}}
The problem I've run into is that I need to #(apply dissoc % fixed-keys)
before the :map-of
schema is evaluated for any map matching this pattern.
Maybe there's a better way?sorry, no, but there is an issue for that: https://github.com/metosin/malli/issues/43 @U09EGLJLB