本文整理汇总了Python中app.exceptions.ValidationError方法的典型用法代码示例。如果您正苦于以下问题:Python exceptions.ValidationError方法的具体用法?Python exceptions.ValidationError怎么用?Python exceptions.ValidationError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app.exceptions
的用法示例。
在下文中一共展示了exceptions.ValidationError方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: from_json
# 需要导入模块: from app import exceptions [as 别名]
# 或者: from app.exceptions import ValidationError [as 别名]
def from_json(json_post):
body = json_post.get('body')
if body is None or body == '':
raise ValidationError('post does not have a body')
return Post(body=body)
示例2: from_json
# 需要导入模块: from app import exceptions [as 别名]
# 或者: from app.exceptions import ValidationError [as 别名]
def from_json(json_post):
body = json_post.get('body')
title = json_post.get('title')
if body is None or body == '':
raise ValidationError('post does not have a body')
if title is None or title == '':
raise ValidationError('post does not have a title')
return Post(body=body,title=title)
示例3: from_json
# 需要导入模块: from app import exceptions [as 别名]
# 或者: from app.exceptions import ValidationError [as 别名]
def from_json(json_post):
body = json_post.get('body')
if body is None or body == '':
raise ValidationError('note does not have a body')
return Note(body=body)
示例4: from_json
# 需要导入模块: from app import exceptions [as 别名]
# 或者: from app.exceptions import ValidationError [as 别名]
def from_json(json_post):
title = json_post.get('title')
body = json_post.get('body')
if body is None or body == '':
raise ValidationError('post does not have a body')
return Todo(title,body)