-
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
explain
doesn't return all errors for sequence schemas
#411
Comments
In the first case the "input remaining" comes is due to the fact that In the second case there is no chance to run out of input because So it is working as intended but really it answers "where would The relevant code is in |
That makes sense, I'll close this issue. Thanks! Do you have any plans to implement that higher level input validation? My use case is that I'm trying to generate a human-readable message when schema validation fails, ideally describing all the ways in which the input doesn't match the schema. |
Not that I know of. I suspect it would get complicated and only benefit your use case (which is quite common, though). The complications would be limited to #387 would also require resynchronization after invalid elements like in your second example so maybe these are piling up..?
Except in your first example where just "should be an int" would be ideal 😄 |
OK, thanks for you help @nilern! |
Hi, I've run into some unexpected (but not necessarily incorrect) behaviour when calling
malli/explain
with sequence schemas. It seems to stop searching for errors after encountering an invalid element, whereas I'd expect it to return all errors, including errors due to too few/many elements.For example, if you run
(malli/explain [:repeat {:max 1} int?] ["a"])
you get:I'd expect to see the first error, but not the second (
:malli.core/input-remaining
). You also get the reverse problem when there are too few elements in a sequence, for example running(malli/explain [:repeat {:min 2} int?] ["a"])
you get:Here I'd expect a second error with type
:malli.core/end-of-input
.Is this working as expected? If not, if you could point me to roughly the area of the code I need to change, I'll attempt to make a PR :)
The text was updated successfully, but these errors were encountered: