forms.py 文件源码

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

项目:specktre 作者: alexwlchan 项目源码 文件源码
def validate_hex(form, field):
    data = field.data

    error = ValidationError('%r is not a valid hex color')

    # Strip a leading # for the hex number
    if data.startswith('#'):
        data = data[1:]

    if len(data) not in (3, 6):
        raise error

    if any(c not in string.hexdigits for c in data):
        raise error
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号