Giter Site home page Giter Site logo

il_tz's Introduction

IL_TZ

Rust Publish Crates.io Docs.rs License

A Rust library for working with Israeli ID numbers (TZ is the Hebrew acronym for "ID").

Install (CLI)

Download the binary for your system from the latest release

You can also install it using cargo install:

cargo install il_tz --features cli

Usage (CLI)

> iltz --help
Validate Israeli ID numbers (TZ)

Usage: iltz.exe [TZ]... [COMMAND]

Commands:
  generate  Generates a list of valid TZ values
  help      Print this message or the help of the given subcommand(s)

Arguments:
  [TZ]...  A list of ID numbers (TZ) to validate

Options:
  -h, --help  Print help

CLI Examples

> iltz 999999998 999999999
999999998 true
999999999 false

> iltz generate 50 100
000000059
000000067
000000075
000000083
000000091
000000109

As a dependency

To use it in your own Rust projects, run this command:

cargo add il_tz

Alternatively, add this to your Cargo.toml:

[dependencies]
il_tz = "0.1.3"

Warning Verify the latest version number on crates.io.

Rust Example

This example shows how to convert an integer to a TZ, how to convert a string to a TZ, and validating them.

use il_tz::{int2tz, str2tz, tz2str, validate};

fn main() {
    // A valid TZ example
    let valid = int2tz(999_999_998).unwrap();
    println!("{} {}", tz2str(&valid), validate(&valid));

    // An invalid TZ example
    let invalid = int2tz(999_999_999).unwrap();
    println!("{} {}", tz2str(&invalid), validate(&invalid));

    // Leading zeros can be used or omitted
    let tz1 = str2tz("000000141").unwrap();
    let tz2 = str2tz("00141").unwrap();
    let tz3 = int2tz(141).unwrap();
    assert_eq!(tz1, tz2);
    assert_eq!(tz1, tz3);
}

Note This library does not validate the ID number (TZ) against any sort of population database, it only validates it mathematically.

License / Warranty

This library is licensed under the MIT license (which means it's free to use, reuse, repackage etc.) See the LICENSE file for more information. This library is provided as-is, without any warranty. Use at your own risk.

il_tz's People

Contributors

dependabot[bot] avatar ofersadan85 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.