All Python ORM and form frameworks love to define own field/schema model. This seems to lead to a situation where they define their own validation functions too.
- Django local flavour defines phone number validations for different countries
- Misc. regular expression validators in Plone’s Archetypes content type subsystem
- Every framework define their own email validator, with various regular expressions
Isn’t writing one’s own validation code a bit redundant and exactly “reinventing the wheel” what open source principles so hard try to avoid? Could validation be a low hanging fruit to share among fellow Python projects? As I see it, for the simple data validation, like email and URL, the core code could be easily shared and different Python projects. You basically want just method is_valid_phonenumber(str) and then framework specific way to raise the error to the user.
Do such frameworks already exist? At least I haven’t seen one being used in any big Python project yet 🙁
… or is validation so complex thing, so that validation functions must be tightly integrated with the parent framework and I am missing some big things (like locales, etc.) here?