l.a.v.username : module documentation

Part of lp.app.validators

Validators for the clean-username (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
def sanitize_username(username):

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'
def valid_username(username):

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
def username_validator(username):
Return True if the username is valid, or raise a LaunchpadValidationError.
API Documentation for Launchpad, generated by pydoctor at 2019-10-19 00:00:05.