本文整理匯總了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)