Function is_username_valid

Source
pub fn is_username_valid(username: &str) -> bool
Expand description

Is the proposed user name valid?

A username is valid when it

  • is nonempty
  • comprises ASCII alphanumeric characters, dashes, dots, and underscores
  • has alphanumeric first and last characters

In particular, this ensures that a valid username is also a valid URL. Similar rules for usernames are enforced by sites such as GitHub.