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
no validating collection attributes #39
Comments
I guess |
This is fairly easy to do if you just write your own validator. There will almost always be a need to do that for when you want to validate not just an object's type, but that it falls in a certain range, e.g. non-negative integer. |
A |
Is this still something that's worth adding ? I was thinking of something like: If a more generic option is recommended, like
@hynek could you please comment on this ? |
The overall problem is that while those validators look useful, in practice you usually need more sophisticated validation and end up using a true validation framework anyway (that can be used from within attrs just fine). So I'm not sure this is really worth adding and whether we should get on the slippery slope of growing an inadequate validation framework that will just lead to people asking for more features and yet us never reach the power of something like voluptuous? |
@hynek is this something that's worth having as a separate library, eventually added here https://github.com/python-attrs/attrs/wiki/Extensions-to-attrs that would provide validators to containers ? We have a version currently that allows you to create validators for containers ( Does it makes sense to have this alongside the typing capabilities specified here ? |
I'm fine with adding anything that's useful to the wiki! So far I had no reason to remove anything. That said, I believe this ticket has been already fixed in #425! Yeah, I can be inconsistent too. 🙈 |
currently its not possible to declare an attribute that's something like a
list of Elements
or amapping of string to integer
The text was updated successfully, but these errors were encountered: