tckimlik 0.1.0

Validate Turkish national identification numbers (T.C. Kimlik No). A faithful port of the algorithm used by python-stdnum. Zero deps, no_std.
Documentation
  • Coverage
  • 100%
    9 out of 9 items documented2 out of 6 items with examples
  • Size
  • Source code size: 25.15 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 212.14 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 3s Average build duration of successful builds.
  • all releases: 3s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • trananhtung/tckimlik
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • trananhtung

tckimlik

All Contributors

crates.io docs.rs CI license

Validate Turkish national identification numbers (T.C. Kimlik No.).

The Turkish Identification Number (Türkiye Cumhuriyeti Kimlik Numarası) is an 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.

  • Zero dependencies, #![no_std]
  • is_valid, validate, calc_check_digits, compact
  • Differential-tested against python-stdnum (60k cases)

Install

[dependencies]
tckimlik = "0.1"

Usage

use tckimlik::{is_valid, validate, calc_check_digits};

assert!(is_valid("17291716060"));
assert!(!is_valid("17291716050")); // wrong check digit
assert!(!is_valid("07291716092")); // must not start with 0

assert_eq!(validate(" 17291716060 ").unwrap(), "17291716060"); // trims whitespace
assert_eq!(calc_check_digits("172917160").unwrap(), "60");      // the two check digits

The number is valid when it has 11 digits, does not start with 0, and its last two digits equal check1 = (10 - Σ wᵢ·dᵢ) mod 10 and check2 = (check1 + Σ dᵢ) mod 10 computed over the first nine digits (weights 3,1,3,1,…).

Contributors ✨

This project follows the all-contributors specification. Contributions of any kind are welcome — code, docs, bug reports, ideas, reviews! See the emoji key for how each contribution is recognized, and open a PR or issue to get involved.

Thanks goes to these wonderful people:

License

Licensed under either of MIT or Apache-2.0 at your option.