Skip to main content

normalize_user_code

Function normalize_user_code 

Source
fn normalize_user_code(input: &str) -> String
Expand description

Normalize a user-entered user_code into the canonical XXXX-XXXX shape.

Uppercases, strips everything that is not alphanumeric (so a missing or extra hyphen and surrounding whitespace are tolerated), and re-inserts the single group separator when exactly eight characters remain. Malformed input is returned uppercased-and-stripped and will not match any stored code.