def validate_user_name(ctx, param, value: str) -> str:
"""Validates if ``value`` is a correct user name.
Parameters
----------
value : str
Possible user name.
Returns
-------
value : str
Valid user name.
Raises
------
click.BadParameter
If user name is not valid for unix systems.
"""
if re.fullmatch(r'^[a-z][a-z0-9_]{5,}', value):
return value
else:
raise click.BadParameter(
'User names can only contain 0-9, a-z and _.')
validators.py 文件源码
python
阅读 35
收藏 0
点赞 0
评论 0
评论列表
文章目录