Fork me on GitHub

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
                [: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

 {:run :app/init
  :ok {:next :do-work}
  :fail {:next :done}}

 {:run :app/process-queue
  :ok {:next :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: @U09EGLJLB

👍 2
🙏 2