-
Notifications
You must be signed in to change notification settings - Fork 19
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
Support validation before and after conversion #37
Comments
Example use case: I want to use a smart properties class to validate/handle a ISO8601 date string. So I want smart_properties to do the following:
In this case, you need to check |
While I understand that having this as a core feature would be nice, I can think of two other ways to implement this without the need for a core feature:
If I understand it correctly, you'd nonetheless need both a accept before and after the conversion. Just because the string has a valid format, doesn't necessarily mean that the value makes any sense (think leap years) |
In my specific use case, I don't want to raise an exception. The whole point of the class would be to validate/prepare a combination of given params. If it raises, I would need another layer above the class to handle these exceptions. I don't want the converter to return I personally think that smart_properties can become very handy for input validation - but in real world scenarios with user input, we should have one more callback before the converter to make sure the converter does not crash. |
There is no harm in adding a |
By the way, I can highly recommend using dedicated objects for complex validation and conversion operations: SmartProperties advanced input validation. |
👍 |
In some scenarios, it might be necessary to perform validation before performing the conversion. This is currently unsupported.
The text was updated successfully, but these errors were encountered: