Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rodolfoghi/cpf-util-rust
CPF utils written in Rust
https://github.com/rodolfoghi/cpf-util-rust
Last synced: 13 days ago
JSON representation
CPF utils written in Rust
- Host: GitHub
- URL: https://github.com/rodolfoghi/cpf-util-rust
- Owner: rodolfoghi
- License: mit
- Created: 2020-03-31T02:51:34.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-10-03T00:43:09.000Z (about 4 years ago)
- Last Synced: 2024-10-05T17:18:10.441Z (about 1 month ago)
- Language: Rust
- Homepage: https://crates.io/crates/cpf_util
- Size: 17.6 KB
- Stars: 7
- Watchers: 3
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/rodolfoghi/cpf-util-rust/Rust) ![Crates.io](https://img.shields.io/crates/v/cpf-util) ![Crates.io](https://img.shields.io/crates/d/cpf-util) ![GitHub issues](https://img.shields.io/github/issues/rodolfoghi/cpf-util-rust)
# CPF util
CPF util inspired in [brazilian-utils/cpf](https://github.com/brazilian-utils/brazilian-utils/blob/master/src/utilities/cpf/index.ts).
## Usage
Add the following to your `Cargo.toml`:
```rust
[dependencies]
cpf_util = "0.1.1"
```## Examples
Format:
```rust
use cpf_util as cpf;fn main() {
println!("{}", cpf::format("94389575104")); // 943.895.751-04
println!("{}", cpf::format("94389575104000000")); // 943.895.751-04
println!("{}", cpf::format("943.?ABC895.751-04abc")); // 943.895.751-04
}
```Validate:
```rustuse cpf_util as cpf;
fn main() {
println!("{}", cpf::is_valid("foo391.838.38test0-66"); // false
println!("{}", cpf::is_valid("40364478829")); // true
println!("{}", cpf::is_valid("962.718.458-60")); // true
}
```