-
Notifications
You must be signed in to change notification settings - Fork 24
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
consider shorting down error message on sequence failure #110
Comments
Thanks for submitting this! I agree, the output is quite verbose in cases like this. I’ll think more about how I can shorten the output without losing useful context. |
@bhb if I may add. Would it also be possible to add a bit more context to the error report? In this particular case, For that I had to switch back to Clojure |
Thanks for that additional information! Yes, I’ll also look at how to best add more context in this case. FWIW, if Expound is omitting too much information, you can use “custom-printer” with “:show-valid-values?” set to true. The API is a bit inconsistent right now (I plan to simplify things for the beta) so let me know if you have any trouble getting this working. |
@carocad Here's the code for that: (binding [s/*explain-out* (expound/custom-printer {:show-valid-values? true})]
(s/explain (s/coll-of int?) [1 2 :3]))
;;-- Spec failed --------------------
;;
;; [1 2 :3]
;; ^^
;;
;;should satisfy
;;
;; int?
;;
;;-------------------------
;;Detected 1 error I realize that's not intuitive, but I'll be making this easier at some point. Until then, it may be easiest to wrap it up in a function. Hope that helps! |
@bhb Thanks for the info Using I think that ideally the failing value should show a bit of the context around (enough to know where the problem is) but not the complete datastructure; otherwise the failing value would get lost among the noise. I know that is a very hard thing to do, though :/ PS: I avoided pasting the error message here, so please let me know if it would help you somehow |
Yes, it’s a bit tricky. Thanks for letting me know about your use case . It’s very helpful to know which cases need improvement. I’ll think more about this. |
@bhb i just had an idea about how to approach this problem. Instead of using 'show valid values' I think the concept of This is (not by surprise) the same way that most Clojure stacktrace libraries work since those also contain lots of data. Hope it helps :) |
Ah, that’s a good idea, thanks! |
I'm also experiencing the same issue as @carocad and my hacked-together solution was simple: capture the printed string from
and replace each matching string with an empty string. It's a decent solution for my limited use-case, but ideally a similar regex replace would be implemented in the printer itself. |
@kelvinqian00 Thanks for posting this workaround! I agree this is not ideal. I’m thinking about ways to make this behavior optional. |
For one of my api endpoints I have a quite long response which is compressed of several so-called
steps
. Each step is an object on its own.The problem arises when one of the last item of the validation fails. It seems that
expound
simply replaces each object in the sequence with...
which is fine for short sequences but for longer ones becomes a problem (See output below)The text was updated successfully, but these errors were encountered: