Class AccountProfileRules
The rules for the optional contact and identity details on an account.
public static class AccountProfileRules
- Inheritance
-
AccountProfileRules
- Inherited Members
Remarks
One copy, here, because three surfaces accept these fields — the game's account creation, the Control Panel's registration, and the panel's self-service — and the database is the one layer all three write through. A rule held in each would be three rules by the second release.
Fields
InvalidDiscordUsernameError
The one refusal for a Discord username that is not one.
public const string InvalidDiscordUsernameError = "Enter your Discord username as it appears on your profile, for example fishfan or FishFan#1234."
Field Value
MaxAddressLength
Longest postal address accepted.
public const int MaxAddressLength = 512
Field Value
MaxCountryLength
Longest country or region accepted.
public const int MaxCountryLength = 64
Field Value
MaxDiscordTagLength
Longest stored Discord name: a username, #, and a four-digit discriminator.
public const int MaxDiscordTagLength = 37
Field Value
MaxDiscordUsernameLength
Longest Discord username Discord allows, not counting a discriminator.
public const int MaxDiscordUsernameLength = 32
Field Value
MaxRealNameLength
Longest real name accepted.
public const int MaxRealNameLength = 128
Field Value
MinDiscordUsernameLength
Shortest Discord username Discord allows.
public const int MinDiscordUsernameLength = 2
Field Value
Methods
NormalizeDiscordUsername(string?)
Normalises a Discord username in either form Discord uses: a unique username (fishfan), or
a name with its four-digit discriminator (FishFan#1234).
public static string? NormalizeDiscordUsername(string? input)
Parameters
inputstring
Returns
- string
The normalised username, or null when it is not one.
Remarks
Trimmed, a leading @ dropped, and lowercased, because Discord matches both forms without
regard to case.
A unique username is 2 to 32 lowercase letters, digits, underscores and periods, never two periods
together. A name with a discriminator is the older form, whose names were freer — capitals, spaces,
most of Unicode — so its name part is held only to its length and to what Discord never allowed in
one: @, #, :, a code fence, control characters. The discriminator is exactly
four digits.
Anything in neither form is refused rather than guessed at: the bot looks the name up exactly, and a DM sent to the wrong person is a verification code in a stranger's hands.
NormalizePhone(string?)
Normalises a phone number to E.164: a leading + and 8 to 15 digits.
public static string? NormalizePhone(string? input)
Parameters
inputstring
Returns
- string
The normalised number, or null when it is not one.
Remarks
Spaces, hyphens, dots and parentheses are dropped, because that is how people write numbers.
A leading 00 becomes +. A number without a country code is refused rather than
guessed at: an SMS sent to the wrong country's number is a verification code in a stranger's
hands.
TryValidate(AccountProfileData, out AccountProfileData, out string)
Validates and normalises a profile. Blank optional fields become null.
public static bool TryValidate(AccountProfileData input, out AccountProfileData clean, out string error)
Parameters
inputAccountProfileDataWhat was submitted.
cleanAccountProfileDataThe profile to store.
errorstringWhy it was refused, written for the person who filled the form in.