swedish_postal_codes

Crates.ioswedish_postal_codes
lib.rsswedish_postal_codes
version0.2.0
sourcesrc
created_at2021-12-15 22:25:28.425867
updated_at2021-12-15 22:25:28.425867
descriptionValidate Swedish postal codes
homepagehttps://github.com/bombsimon/swedish-postal-codes
repositoryhttps://github.com/bombsimon/swedish-postal-codes
max_upload_size
id498861
size273,622
Simon Sawert (bombsimon)

documentation

README

Swedihs Postal Codes

Validate Swedish postal codes in Rust. The project comes bundled with a list of valid postal codes. None of them will be revoked manually but it's quite uncommon for those to get removed. It's however more common for new postal codes to be added. To support this, the library has an optional fallback API that will check for valid codes if not found in the CSV.

Note by turning this feature on, every invalid request will perform a new HTTP request.

Usage

[dependencies]
swedish_postal_codes = "0.2.0"
use swedish_postal_codes::PostalCode;

fn main() {
    let fallback = true;
    let pc = PostalCode::new(fallback);

    let from_integer = 11220;
    println!("{}: {}", from_integer, pc.valid(from_integer));

    let from_string = "11120";
    println!("{}: {}", from_string, pc.valid(from_string));

    let invalid = 55555i64;
    println!("{}: {}", invalid, pc.valid(invalid));
}
Commit count: 3

cargo fmt