Part of lp.app.validators
Person.name
) attribute.Function | sanitize_username | Remove from the given username all characters that are not allowed. |
Function | valid_username | Return True if the username is valid, otherwise False. |
Function | username_validator | Return True if the username is valid, or raise a |
Remove from the given username all characters that are not allowed.
The characters not allowed in Launchpad usernames are described by
username_invalid_pattern
.
>>> sanitize_username('foo_bar') 'foobar' >>> sanitize_username('foo.bar+baz') 'foobarbaz' >>> sanitize_username('-#foo -$fd?.0+-') 'foo-fd0'
Return True if the username is valid, otherwise False.
Launchpad username
(Person.name
) attribute is designed to serve as
an human-friendly identifier to a identity across multiple services.
>>> valid_username('hello') True >>> valid_username('helLo') False >>> valid_username('hel|o') False >>> valid_username('hel.o') False >>> valid_username('hel+o') False >>> valid_username('he') False >>> valid_username('hel') True >>> valid_username('h' * 32) True >>> valid_username('h' * 33) False >>> valid_username('-he') False >>> valid_username('he-') False