malli icon indicating copy to clipboard operation
malli copied to clipboard

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

Open theronic opened this issue 1 year ago • 1 comments

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 avatar Sep 02 '24 07:09 theronic

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?

theronic avatar Sep 02 '24 08:09 theronic

If you have require on the ns, it should load normally. (malli.dev/start!) is a good way to get detailed errors. Closing this.

ikitommi avatar Jan 01 '25 11:01 ikitommi