-
Notifications
You must be signed in to change notification settings - Fork 216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should error reports include schema forms? #789
Comments
It is a feature. Tools like
#?(:clj (defmethod print-method ::schema [v ^java.io.Writer w] (.write w (pr-str (-form ^Schema v))))) Given(def schema
(m/schema
::tuple
{:registry {:tuple (m/-tuple-schema)
:int (m/-int-schema)
::tuple [:tuple ::int ::int]
::int :int}}))
(m/form schema)
; => :user/tuple as Schema (works)(-> schema
(m/explain "invalid")
(me/humanize))
; ["invalid type"] as form (blows)(-> schema
(mu/explain-data "invalid")
(me/humanize))
; =throws=> :malli.core/invalid-schema {:schema :user/int} |
Thanks for the context! Here's the problem I have with instrumentation. On the master branch, using CIDER, this is what gets displayed when an instrumented function reports an error: The exception message, in light blue, shows the result of calling The If I instead call Data explainers seem much more appropriate for error reporting in general, but using them from What do you recommend? |
I see. There are at least two options:
it's called like this in (report ::invalid-input {:input input, :args args, :schema schema}) I think the "present schemas as forms" walker could be a optional utility in |
While working on a fix for #770 I've found it really difficult to make sense of validation errors because reports include reified schema objects:
There's nothing in this output that relates
#<malli.core$_simple_schema$reify$reify__21622@2ec70b0e>
to a userland schema. This is exacerbated during instrumentation because of the loss of local reasoning.Looking at the readme, it seems like this is what's expected:
I could spot three groups of functions involved in this issue:
malli.core/-fail!
,explainer
s andmalli.impl.util/-error
. Could you clarify if none/some/all of these should-form
schemas prior to reporting an error?The text was updated successfully, but these errors were encountered: