isValidTwitchUsername

Checks if a string is a valid Twitch username.

They must be 4 to 25 characters and may only contain letters, numbers and underscores.

version(TwitchSupport && WithTwitchPlugin)
package
isValidTwitchUsername
(
const string username
)

Parameters

username string

The string to check.

Return Value

Type: auto

true if the string is a valid Twitch username; false if not.

Examples

{
    enum username = "zorael";
    assert(username.isValidTwitchUsername);
}
{
    enum username = "zårael";
    assert(!username.isValidTwitchUsername);
}
{
    enum username = "zorael_";
    assert(username.isValidTwitchUsername);
}
{
    enum username = "zorael-";
    assert(!username.isValidTwitchUsername);
}
{
    enum username = "z0rael";
    assert(username.isValidTwitchUsername);
}
{
    enum username = "z0r";
    assert(!username.isValidTwitchUsername);
}
{
    enum username = string.init;
    assert(!username.isValidTwitchUsername);
}
{
    enum username = "1234567890123456789012345";
    assert(username.isValidTwitchUsername);
}
{
    enum username = "12345678901234567890123456";
    assert(!username.isValidTwitchUsername);
}
{
    enum username = "#zorael";
    assert(!username.isValidTwitchUsername);
}