ssn
U.S. Social Security Number (SSN) parsing and validation for Rust.
Usage
use Ssn;
// Parse from string with dashes
let ssn: Ssn = "123-45-6789".parse.unwrap;
assert_eq!;
// Parse from string without dashes
let ssn: Ssn = "123456789".parse.unwrap;
assert_eq!;
// Access components
assert_eq!;
assert_eq!;
assert_eq!;
// Create from components
let ssn = new.unwrap;
Validation
Validates per SSA rules:
- Area number (first 3 digits) cannot be 000, 666, or 900-999
- Group number (middle 2 digits) cannot be 00
- Serial number (last 4 digits) cannot be 0000
use ;
// Invalid area
assert!;
// Invalid format
assert!;
Privacy
The Debug implementation masks sensitive digits:
let ssn: Ssn = "123-45-6789".parse.unwrap;
assert_eq!;
License
Apache-2.0