forked from orbit-oss/flask
verbage
This commit is contained in:
parent
a8498b6859
commit
bd4921194e
1 changed files with 3 additions and 4 deletions
|
|
@ -54,7 +54,8 @@ Here is an example document (put this also into :file:`app.py`, e.g.)::
|
|||
def validate(value):
|
||||
if len(value) <= length:
|
||||
return True
|
||||
raise ValidationError('%s must be at most {0} characters long'.format(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):
|
||||
|
|
@ -76,9 +77,7 @@ Here is an example document (put this also into :file:`app.py`, e.g.)::
|
|||
|
||||
This example shows you how to define your schema (named structure), a
|
||||
validator for the maximum character length and uses a special MongoKit feature
|
||||
called `use_dot_notation`. When you define a ValidationError, you can add the `%s`
|
||||
into the format string to have the value placed in there for the final error message.
|
||||
ValueErrors can also be thrown as an alternative. Per default MongoKit behaves like a python
|
||||
called `use_dot_notation`. Per default MongoKit behaves like a python
|
||||
dictionary but with `use_dot_notation` set to ``True`` you can use your
|
||||
documents like you use models in nearly any other ORM by using dots to
|
||||
separate between attributes.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue