metosin / malli

High-performance data-driven data specification library for Clojure/Script.
Eclipse Public License 2.0
1.48k stars 209 forks source link

How to get more verbose schema error output than `:malli.core/invalid-schema`? #1103

Open theronic opened 3 weeks ago

theronic commented 3 weeks ago

I'm working on a large Clojure client project with hundreds of Malli schemas. When I try to run tests locally, I just get :malli.core/invalid-schema errors. I tried to instrument using (malli.instrument/instrument!) in the calling namespace, but this does not change error output. Perhaps it does not propagate down to imported namespaces?

I tried to do this:

(def default-schemas
  (mr/custom-default-registry
    (merge
      (m/default-schemas)
      {:my-schemas {}
       ::m/explain-errors true})))

But getting argument errors.

Is there a way to turn on global schema error reporting so I can figure out which schema is causing the invalid-schema error, please?

theronic commented 3 weeks ago

OK, so I managed to trace it down by turning on (malli.dev/start! {:report (pretty/reporter)}) until I found the issue. The cause seems to be that namespaces with Malli schema definitions are not being evaluated until I manually eval them, even though they are in :require. So this is not a Malli issue, but I have no idea how to fix it.

Feel free to close, but maybe someone knows why this is happening?