Skip to content
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

More specific error message for Any() #412

Open
Suor opened this issue Nov 13, 2019 · 1 comment
Open

More specific error message for Any() #412

Suor opened this issue Nov 13, 2019 · 1 comment

Comments

@Suor
Copy link

Suor commented Nov 13, 2019

Now it's:

from voluptuous import Any, Schema

schema = Schema(Any(str, None))
schema(10)
# MultipleInvalid: not a valid value

I would expect something like "expected str or none". I know I can pass msg to Any, but it would be nice to have better default for such a common case.

@spacegaier
Copy link
Collaborator

This error message however would quickly get quite long if there are more than only those two validators in the Any() clause, plus it would need some logic to generate proper language in a generic way, e.g. if there are then further validators such as Range, Contains or NotIn.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants