Crates.io | cnpj-util |
lib.rs | cnpj-util |
version | 0.1.4 |
source | src |
created_at | 2020-04-15 02:06:20.291765 |
updated_at | 2020-10-01 17:34:25.691485 |
description | Format and validate CNPJ, Brazil companies ID number. |
homepage | |
repository | https://github.com/rodolfoghi/cnpj-util-rust |
max_upload_size | |
id | 230352 |
size | 10,123 |
CNPJ util inspired in brazilian-utils/cnpj.
Add the following to your Cargo.toml
:
[dependencies]
cnpj_util = "0.1.2"
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
}
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"));
}