CPF v0.3.0 CPF View Source

CPF module that provides functions to verify if a CPF is valid.

Link to this section Summary

Types

t()

The CPF type. It' composed of eleven digits(0-9]).

Functions

Returns a formatted string from a given cpf.

Initializes a CPF.

Returns true the given cpf is valid, otherwise false.

Link to this section Types

The CPF type. It' composed of eleven digits(0-9]).

Link to this section Functions

Link to this function

format(cpf) View Source
format(cpf :: t()) :: String.t()

Returns a formatted string from a given cpf.

Examples

iex> 563_606_676_73 |> CPF.new() |> CPF.format() "563.606.676-73"

Initializes a CPF.

Examples

iex> CPF.new(563_606_676_73) #CPF<563.606.676-73>

iex> CPF.new("56360667673") #CPF<563.606.676-73>

This function doesn't check if CPF numbers are valid, only use this function if the given String.t or the integer was validated before.

Link to this function

valid?(cpf) View Source
valid?(input :: String.t() | pos_integer()) :: boolean()

Returns true the given cpf is valid, otherwise false.

Examples

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/60.6-676/73")
false

iex> CPF.valid?("563.606.676-72")
false

iex> CPF.valid?("56360667673")
true

iex> CPF.valid?("56360667672")
false