Expand description
§tckimlik — validate Turkish national identification numbers
Validate a Turkish Identification Number (T.C. Kimlik No.) — the 11-digit number
assigned to every citizen of Turkey, whose last two digits are check digits. A faithful
Rust port of the algorithm used by
python-stdnum and the JavaScript ecosystem.
use tckimlik::{is_valid, calc_check_digits};
assert!(is_valid("17291716060"));
assert!(!is_valid("17291716050")); // wrong check digit
assert!(!is_valid("07291716092")); // must not start with 0
// Compute the two check digits from the first nine:
assert_eq!(calc_check_digits("172917160").unwrap(), "60");Zero dependencies and #![no_std].
Enums§
- Error
- Why a number is not a valid T.C. Kimlik No.
Functions§
- calc_
check_ digits - Calculate the two check digits from the first nine characters of
number. - compact
- Strip surrounding whitespace (the minimal representation).
- is_
valid - Whether
numberis a valid T.C. Kimlik No. - validate
- Validate a T.C. Kimlik No., returning the compacted number on success.