malli icon indicating copy to clipboard operation
malli copied to clipboard

Custom Default Options

Open ikitommi opened this issue 5 years ago • 1 comments

what

Instead of allowing one to override just the default registry (using malli.registry/type), one should be able to override the full default options instead.

why

  1. one can configure anything, e.g. override error localization, generators, ...
  2. sci can be passed in via explicit option - there can be schema systems with and without sci in same JVM:
(m/schema 
  [:fn '(fn [x] (> x 10))] 
  {:evaluator malli.sci/evaluator})

how

instead of malli.registry/type, define a malli.core/options with values "default" or "custom". Relevant keys are (at least):

  • :registry (the malli.registry/Registry impl
  • :evaluator, maybe a Protocol for this too.

big change

nah, mostly mechanical port.

ikitommi avatar Jul 23 '20 08:07 ikitommi

maybe:

(malli.core/set-default-options!
 {:registry (malli.core/schemas)
  :malli.sci/options ...
  :malli.core/cache ...})

ikitommi avatar Feb 16 '25 09:02 ikitommi

Let's close this for now to clean up the issue list. Feel free to reopen if the idea moves out of the hammock!

opqdonut avatar Nov 07 '25 07:11 opqdonut