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.
Asked
Active
Viewed 580 times
1

Eugene Tsakh
- 2,777
- 2
- 14
- 27
-
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 – dizzyf Mar 23 '17 at 20:25
-
Perfect. That's works for me well! Thank you! – Eugene Tsakh Mar 23 '17 at 20:35
-
1@dizzyf, how to mark your comment as correct answer? – Eugene Tsakh Mar 23 '17 at 20:37
-
I'll paste it as an actual answer... Thanks :) – dizzyf Mar 24 '17 at 14:25
1 Answers
1
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

dizzyf
- 3,263
- 19
- 29