-
Notifications
You must be signed in to change notification settings - Fork 215
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
Schema validation quits on first error #8
Comments
This is by design. I agree, schema needs to be changed to allow this. Do you have any implementation ideas? All in all, do you like the error-handling API? Things like |
From a quick glance at Then at the end, you see what you got and I appreciate the error handling API's simplicity. Some things I noticed when playing around a bit:
I know many larger validation libraries provide a lot of built-in validators with very granular error messages. It doesn't seem like schema is meant to provide lots of built-in validators (some other project could easily create such a library). However, it might be useful to show how one could build more complicated validation. Is is possible to implement a "confirm password field must match password" validation, for example? |
Maybe I can steal something more from voluptous, for example, how it constructs error-messages like:
Also, now that I look at voluptous I can't remember why the hell did I make another schema-validation library. So, collecting errors in a dict is probably not the best idea, since the data could be anything, not just a dict.
I never saw an exception being returned from a function. What is the benefit of it?
You are very welcome to make a pull request with those examples into README, also you can try rewording things in README, if you think you can improve it.
I actually don't mind. It just happens I can validate all my use-cases with lambdas and types. (My use-cases are mostly docopt and yaml/json).
Do you mean something like that? lambda password: re.match('^[0-9a-zA-Z]{6,50}$', password) Or maybe something database-related? Example with imaginary ORM: lambda password: Users.objects.where(password_hash=sha1(password).hexdigest()) |
Well, the data could be, but the error messages are probably strings? Or do you mean that you might have nested things?
Nevermind :)
Yes, I appreciate that! I came upon this project when looking to validate data for a rather big project, with SQLAlchemy models. It looks very nice in how it succinctly describes what's valid and what's not.
Maybe I will :)
No, I mean if you have a user registration form and the user has to type in their password twice, to make sure that it's not mistyped. In general, is it possible to validate fields "together"? For example, if "a" is provided, "b" must also be provided and so forth (quite common in command line utilities). |
Yes, how do you see such a dictionary, say, for a list of dicts?
Ah! Interesting... Need to think of API for that. If you find yourself using the same validators again and again, I will consider including them |
I might work on this as I need it. Any new idea on the implementation? Otherwise I'll try something. |
@charlax nice, go ahead! |
Did anyone ever come up with a fix or workaround that is plausible? |
Not with Schema. Note that voluptuous does have a decent pattern for this where a |
I doubt this is going to happen by now. As the author of the issue, I'm closing it. |
Given a simple schema:
If I submit this with bad data for both fields, only one error will be reported:
I understand that this might be intentional, but in my opinion it hampers the user experience since they have to resubmit and resubmit. Is there a way to get "all" validation errors at once?
The text was updated successfully, but these errors were encountered: