add username's option
This commit is contained in:
@@ -1079,6 +1079,18 @@ class URLOption(DomainnameOption):
|
||||
raise ValueError(_('invalid url, should ends with filename'))
|
||||
|
||||
|
||||
class UsernameOption(Option):
|
||||
__slots__ = tuple()
|
||||
_opt_type = 'username'
|
||||
#regexp build with 'man 8 adduser' informations
|
||||
username_re = re.compile(r"^[a-z_][a-z0-9_-]{0,30}[$a-z0-9_-]{0,1}$")
|
||||
|
||||
def _validate(self, value):
|
||||
match = self.username_re.search(value)
|
||||
if not match:
|
||||
raise ValueError(_('invalid username'))
|
||||
|
||||
|
||||
class FilenameOption(Option):
|
||||
__slots__ = tuple()
|
||||
_opt_type = 'file'
|
||||
|
Reference in New Issue
Block a user