malli

https://github.com/metosin/malli :malli:
robert-stuttaford 2021-06-13T15:09:26.126300Z

is there a way to do this :enum {:error/fn entity.validation/malli-humanize-enum-error} for all enums in the spec, perhaps when calling m/humanize ? otherwise i could walk the spec and inject them

ikitommi 2021-06-13T17:12:18.129300Z

@robert-stuttaford humanize takes an :errors option, where you can override :enum handling. Walking is another way to do it. There might be others too

robert-stuttaford 2021-06-13T18:25:48.130300Z

thanks @ikitommi - can you point me to example of the :errors option specifically overriding the printing of errors for a specific spec type like :enum that i can work from, please?

ikitommi 2021-06-14T11:18:05.131600Z

I would say (assoc me/default-errors :enum {:error/fn {:en my-fn-here}}) just to make sure that the whole :enum map is overridden, can’t recall which one is picked first, :error/fn or :error/message if both are present

robert-stuttaford 2021-06-13T20:10:56.130700Z

ah so:

(assoc-in me/default-errors [:enum :error/fn :en] my-fn-here)

robert-stuttaford 2021-06-13T20:10:59.130900Z

thanks!

👍 1