python类ValidationError()的实例源码

db.py 文件源码 项目:morpy 作者: iurykrieger96 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def to_python(value):
        try:
            return ObjectId(base64_decode(value))
        except (InvalidId, ValueError, TypeError):
            raise ValidationError()
converter.py 文件源码 项目:BlogSpider 作者: hack4code 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def to_python(self, value):
        try:
            return date(*(int(_) for _ in value.split('-')))
        except ValueError:
            raise ValidationError('invalid date format')
converter.py 文件源码 项目:BlogSpider 作者: hack4code 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def to_python(self, value):
        try:
            return ObjectId(value)
        except InvalidId:
            raise ValidationError('invalid id')
app.py 文件源码 项目:relay 作者: trustlines-network 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def to_python(self, value):
        if not is_address(value):
            raise ValidationError()
        value = add_0x_prefix(value)
        return value
utils.py 文件源码 项目:fhir 作者: teffalump 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def to_python(self, value):
        tmp = [None, None, None]
        for k,v in enumerate(value.split('-')):
            if k == 3: raise ValidationError()
            tmp[k]=v
        try:
            tmp[1]=int(tmp[1])
        except:
            raise ValidationError()
        return tmp
utils.py 文件源码 项目:raw-data-repository 作者: all-of-us 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def to_python(self, value):
    try:
      return from_client_participant_id(value)
    except BadRequest as ex:
      raise ValidationError(ex.description)
converters.py 文件源码 项目:uchan 作者: Floens 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def to_python(self, value):
        intval = int(value)
        if not 0 < intval <= 2 ** 32:
            raise ValidationError()
        model = self.resolve_id(intval)
        if not model:
            raise ValidationError()
        return model
converters.py 文件源码 项目:uchan 作者: Floens 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def to_python(self, value):
        if not validation.check_board_name_validity(value):
            raise ValidationError()
        model = board_service.find_board(value)
        if not model:
            raise ValidationError()
        return model
converters.py 文件源码 项目:GridLight-Server 作者: Lunabit 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def to_python(self, value):
        if len(str(value)) != 2 or not str(value).isalpha():
            raise ValidationError("State must be a valid two-character code.")

        return str(value).upper()
flask_variables.py 文件源码 项目:Python-Microservices-Development 作者: PacktPublishing 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def to_python(self, value):
        if value in _USERS:
            return _USERS[value]
        raise ValidationError()


问题


面经


文章

微信
公众号

扫码关注公众号