validations.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:drf-url-filters 作者: manjitkumar 项目源码 文件源码
def StrictlyAlphanumeric(msg=None):
    '''
    Checks whether a value is:
        - str or unicode, and
        - composed of both alphabets and digits
    '''
    def fn(value):
        if not (
            isinstance(value, basestring) and
            value.isalnum() and not
            value.isdigit() and not
            value.isalpha()
        ):
            raise Invalid(msg or (
                'Invalid input <{0}>; expected an integer'.format(value))
            )
        else:
            return value
    return fn
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号