加入marshmallow数据验证

This commit is contained in:
mkg
2021-06-07 22:57:21 +08:00
parent 375d3a10b2
commit f93a36c094
6 changed files with 72 additions and 9 deletions
+4 -4
View File
@@ -1,6 +1,6 @@
import datetime
from applications.models import db, ma
from marshmallow import fields
from marshmallow import fields,validate
class Dept(db.Model):
@@ -25,7 +25,7 @@ class DeptSchema(ma.Schema): # 序列化类
deptName = fields.Str(attribute="dept_name")
leader = fields.Str()
phone = fields.Str()
email = fields.Str()
email = fields.Str(validate=validate.Email())
address = fields.Str()
status = fields.Str()
sort = fields.Str()
status = fields.Str(validate=validate.OneOf(["0", "1"]))
sort = fields.Integer()