Crates.io | cpf_util |
lib.rs | cpf_util |
version | 0.1.1 |
source | src |
created_at | 2020-04-02 03:20:43.174785 |
updated_at | 2020-10-03 00:47:36.544233 |
description | Format and validate CPF, Brazil's ID number. |
homepage | |
repository | https://github.com/rodolfoghi/cpf-util-rust |
max_upload_size | |
id | 225392 |
size | 9,400 |
CPF util inspired in brazilian-utils/cpf.
Add the following to your Cargo.toml
:
[dependencies]
cpf_util = "0.1.1"
Format:
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:
use 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
}