cnpj-util

Crates.iocnpj-util
lib.rscnpj-util
version0.1.4
sourcesrc
created_at2020-04-15 02:06:20.291765
updated_at2020-10-01 17:34:25.691485
descriptionFormat and validate CNPJ, Brazil companies ID number.
homepage
repositoryhttps://github.com/rodolfoghi/cnpj-util-rust
max_upload_size
id230352
size10,123
Rodolfo Ghiggi (rodolfoghi)

documentation

https://docs.rs/cnpj_util

README

GitHub Workflow Status Crates.io Crates.io GitHub issues

CNPJ util

CNPJ util inspired in brazilian-utils/cnpj.

Usage

Add the following to your Cargo.toml:

[dependencies]
cnpj_util = "0.1.2"

Examples

Format:

use cnpj_util as cnpj;

fn main() {
    println!("{}", cnpj::format("46843485000186")); // 46.843.485/0001-86
    println!("{}", cnpj::format("468434850001860000000000")); // 46.843.485/0001-86
    println!("{}", cnpj::format("46.?ABC843.485/0001-86abc")); // 46.843.485/0001-86
}

Validate:

use cnpj_util as cnpj;

fn main() {
    assert_eq!(false, is_valid("12312312312"));
    assert_eq!(false, is_valid("6ad0.t391.9asd47/0ad001-00"));
    assert_eq!(true, is_valid("13723705000189"));
    assert_eq!(true, is_valid("60.391.947/0001-00"));
}
Commit count: 27

cargo fmt