konjingjing 1.0.0

Thai Citizen ID validation library
Documentation
  • Coverage
  • 69.23%
    18 out of 26 items documented2 out of 9 items with examples
  • Size
  • Source code size: 54.0 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 497.0 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 5s Average build duration of successful builds.
  • all releases: 5s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • ninyawee/konjingjing
    2 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • ninyawee

konjingjing

Thai Citizen ID validation library for Rust.

The library name 'kon-jing-jing' (คนจริงจริง) means 'real person' in Thai.

Installation

cargo add konjingjing

Usage

Verify ID

use konjingjing::verify_id;

assert!(verify_id("1112034563562"));        // Valid
assert!(!verify_id("1112034563563"));       // Invalid checksum
assert!(!verify_id("11120345635"));         // Too short

Extract ID Meaning

use konjingjing::get_id_meaning;

let result = get_id_meaning("1101700230703").unwrap();
assert_eq!(result.person_type.code, 1);
assert_eq!(result.person_type.description_th, "คนไทยที่แจ้งเกิดภายในกำหนด");
assert_eq!(result.person_type.description_en, "Thai citizen, birth registered on time");
assert_eq!(result.province.unwrap().name_en, "Bangkok");
assert_eq!(result.amphoe.unwrap().name_th, "ห้วยขวาง");
assert!(result.is_valid);

assert!(get_id_meaning("invalid").is_none());

License

ISC