pub fn normalize_username(username: &str) -> Result<Vec<u8>, IdentityError>Expand description
Normalise a username and return its UTF-8 bytes.
Applies ASCII lowercasing (not Unicode lowercasing, to avoid the Turkish İ
problem) and validates that every character is in [a-z0-9.]. The
normalised form must be 1–32 bytes inclusive.
Dot placement rules (enforced after character validation):
- No leading dot (
".alice"is rejected). - No trailing dot (
"alice."is rejected). - No consecutive dots (
"alice..1"is rejected).
These rules match the on-chain People pallet’s username validity checks and prevent storage key confusion from structurally malformed names.