title: How to test data before it gets stored in a database?
body: <p>I'm writing a python module that will contain some functions that will manipulate a mongodb database. </p>
  
  <p>How can I go about validating input data passed to that function before saving it in database?</p>
  
  <p>For example, lets say one of the function in module is <code>createUser(user)</code> 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.</p>