I'm writing a python module that will contain some functions that will manipulate a mongodb database.
How can I go about validating input data passed to that function before saving it in database?
For example, lets say one of the function in module is createUser(user)
which accepts a python dictionary as argument. This dictionary contains user information to save in the database. I want to create an automated validation routine which checks that the dictionary structure matches the database structure.
I released "pyvaru" (https://github.com/daveoncode/pyvaru) a couple of days ago, it is a simple, flexible and unobtrusive data validation library for Python 3 (3.4+), based on the concept of validation rules.
Quote from the doc: