Merge pull request #1280 from jcomo/mongokit-doc-update

Update mongokit pattern
This commit is contained in:
Markus Unterwaditzer 2014-12-17 13:28:24 +01:00
commit b7dfa6c363

View file

@ -48,12 +48,14 @@ insert query to the next without any problem. MongoKit is just schemaless
too, but implements some validation to ensure data integrity.
Here is an example document (put this also into :file:`app.py`, e.g.)::
from mongokit import ValidationError
def max_length(length):
def validate(value):
if len(value) <= length:
return True
raise Exception('%s must be at most %s characters long' % length)
# must have %s in error format string to have mongokit place key in there
raise ValidationError('%s must be at most {} characters long'.format(length))
return validate
class User(Document):