Search code examples
pythonvalidationsqlalchemycerberus

SQLAlchemy whole model validation with Cerberus


I want to create some universal validation mechanism for all models using cerberus. The goal is to have cerberus schema in model's __schema__ property and perform validation of whole model using this schema each time model's state changed (not necessarily before insert or update). I thought about using events but I'm not sure how to do it and do not miss something.


Solution

  • Based on what you're describing, you might be better off using marshmallow instead of cerberus:

    http://marshmallow.readthedocs.io/en/latest/examples.html#quotes-api-flask-sqlalchemy