CPF
A library to work with CPFs.
CPF is an acronym for "Cadastro de Pessoa FĂsicas," it's a unique number associated with a person that the Brazilian government maintains. With this number, it is possible to check if a person has any irregularity on tax payments, if they are alive and many other status that are provided from Brazilian government services or private company services.
This library provides a validation that checks if the number is a valid CPF
number. The CPF has check digit algorithm is similar to
ISBN 10, you can check
the details in Portuguese here.
Installation
If available in Hex, the package can be installed
by adding cpf to your list of dependencies in mix.exs:
def deps do
[
{:cpf, "~> 0.2.0"}
]
endQuick Start
You verify if the CPF is valid by calling the function CPF.valid?/1:
iex> CPF.valid?(563_606_676_73)
true
iex> CPF.valid?(563_606_676_72)
false
iex> CPF.valid?("563.606.676-73")
true
iex> CPF.valid?("563.606.676-72")
false
iex> CPF.valid?("56360667673")
true
iex> CPF.valid?("56360667672")
falseWhy not other libraries?
This library runs 3 times faster and consume 3 times less memory and work with primitive types, no extra struct is necessary.
Docs
The docs can be found at https://hexdocs.pm/cpf.