Fork me on GitHub
#malli
<
2021-06-13
>
robert-stuttaford15:06:26

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

ikitommi17:06:18

@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-stuttaford18:06:48

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?

robert-stuttaford20:06:56

ah so:

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

ikitommi11:06:05

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