forked from orbit-oss/flask
Merge pull request #1280 from jcomo/mongokit-doc-update
Update mongokit pattern
This commit is contained in:
commit
b7dfa6c363
1 changed files with 3 additions and 1 deletions
|
|
@ -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.
|
too, but implements some validation to ensure data integrity.
|
||||||
|
|
||||||
Here is an example document (put this also into :file:`app.py`, e.g.)::
|
Here is an example document (put this also into :file:`app.py`, e.g.)::
|
||||||
|
from mongokit import ValidationError
|
||||||
|
|
||||||
def max_length(length):
|
def max_length(length):
|
||||||
def validate(value):
|
def validate(value):
|
||||||
if len(value) <= length:
|
if len(value) <= length:
|
||||||
return True
|
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
|
return validate
|
||||||
|
|
||||||
class User(Document):
|
class User(Document):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue