Skip to content

Commit b7dfa6c

Browse files
committed
Merge pull request pallets#1280 from jcomo/mongokit-doc-update
Update mongokit pattern
2 parents 82d7c49 + bd49211 commit b7dfa6c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

docs/patterns/mongokit.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,14 @@ insert query to the next without any problem. MongoKit is just schemaless
4848
too, but implements some validation to ensure data integrity.
4949

5050
Here is an example document (put this also into :file:`app.py`, e.g.)::
51+
from mongokit import ValidationError
5152

5253
def max_length(length):
5354
def validate(value):
5455
if len(value) <= length:
5556
return True
56-
raise Exception('%s must be at most %s characters long' % length)
57+
# must have %s in error format string to have mongokit place key in there
58+
raise ValidationError('%s must be at most {} characters long'.format(length))
5759
return validate
5860

5961
class User(Document):

0 commit comments

Comments
 (0)