Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

brenomfviana/cpf-util-rust

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub Workflow Status Crates.io Crates.io GitHub issues

CPF util

CPF util inspired in brazilian-utils/cpf.

Usage

Add the following to your Cargo.toml:

[dependencies]
cpf_util = "0.1.0"

Examples

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
}

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%