https://github.com/rodolfoghi/cnpj-util-rust
A library focused on solving a common problems that we face daily in the development of applications using CNPJ (Brazil companies ID number).
https://github.com/rodolfoghi/cnpj-util-rust
Last synced: 5 months ago
JSON representation
A library focused on solving a common problems that we face daily in the development of applications using CNPJ (Brazil companies ID number).
- Host: GitHub
- URL: https://github.com/rodolfoghi/cnpj-util-rust
- Owner: rodolfoghi
- License: mit
- Created: 2020-04-15T01:00:47.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-10-01T17:35:06.000Z (over 4 years ago)
- Last Synced: 2024-10-29T21:30:47.119Z (6 months ago)
- Language: Rust
- Homepage: https://crates.io/crates/cnpj-util
- Size: 16.6 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
   
# CNPJ util
CNPJ util inspired in [brazilian-utils/cnpj](https://github.com/brazilian-utils/brazilian-utils/blob/master/src/utilities/cnpj/index.ts).
## Usage
Add the following to your `Cargo.toml`:
```rust
[dependencies]
cnpj_util = "0.1.2"
```## Examples
### Format:
```rust
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:
```rust
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"));
}
```