Skip to content

[Mirror] Parse and generate random CPF and CNPJ, Brazil's ID numbers, using Rust.

License

Unknown and 2 other licenses found

Licenses found

Unknown
LICENSE
Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

ricvelozo/brids-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

103 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

brids

Parse and generate random CPF and CNPJ, Brazil's ID numbers.

Usage

Add the following to your Cargo.toml:

[dependencies]
brids = "0.5"

Features

All dependencies are optional and disabled by default:

  • rand - enable to generate random numbers
  • serde - enable to (de)serialize numbers

no_std mode

To enable no_std mode, just disable the default features:

[dependencies]
brids = { version = "0.5", default-features = false }

Examples

Parse and format:

use brids::{Cnpj, Cpf};

let maybe_valid = "123.456.789-09".parse::<Cpf>();
assert!(maybe_valid.is_ok()); // Checks validity

let old_format = "123.456.789/09".parse::<Cpf>();
assert!(old_format.is_ok()); // Accepts the old format too

let unformatted = "12345678909".parse::<Cpf>().expect("invalid CPF");
let formatted = unformatted.to_string(); // Formats
println!("CPF: {unformatted}"); // Formats too

// Generate random CNPJ and CPF numbers
println!("Random CNPJ number: {}", Cnpj::generate());
println!("Random CPF number: {}", Cpf::generate());

License

brids is licensed under either of the following, at your option:

About

[Mirror] Parse and generate random CPF and CNPJ, Brazil's ID numbers, using Rust.

Topics

Resources

License

Unknown and 2 other licenses found

Licenses found

Unknown
LICENSE
Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published

Languages