pesel 0.1.1

PESEL validation & generation library
Documentation

Travis Build Status AppVeyor Build status

PESEL is a simple Rust library to validate PESEL numbers.

What is PESEL number?

PESEL is national identification number used in Poland. Every citizen of Republic of Poland is assigned PESEL when being born (and since 2015 this should also apply to foreigners living in Poland for more than 2 months).

There are some interesting facts about the PESEL number - find more on Wikipedia

Usage & Examples

This library offers two main features:

a) creating PESEL from String (and performing some checks to make sure PESEL is valid)

use std::str::FromStr;

fn some_function() {
    let pesel_number ="44051401458";
    // you could also use literal as argument for from_str:
    // let pesel = PESEL::from_str("44051401458");
    let pesel = PESEL::from_str(pesel_number);
    match pesel {
        Ok(t) => println!("{}", t),
        _ => panic!("invalid PESEL provided")
    }
}

b) generating PESEL number, based on date of birth of a person and their biological gender


fn some_other_function() {
    let generated_pesel = PESEL::new(1980, 05, 26, PeselGender::Male);
    println!("generted pesel: {}", generated_pesel);
}

Please note that after PESEL number structure is constructed there is no way to change it - it stays immutable forever.

TODO

  • validate PESEL numbers in bulk (ideally: reading from file)