Skip to content

Commit

Permalink
Support for 7 digit as valid CE (#17)
Browse files Browse the repository at this point in the history
Legally we have no restriction on the length of the immigration ID number. At the moment it is only required to validate that it has 6 or 7 digits
  • Loading branch information
CevaMenelao authored Nov 8, 2023
1 parent 742327c commit 5a01161
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/bali.ex
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ defmodule Bali do
iex> Bali.validate(:co, :ce, "123456")
{:ok, "123456"}
iex> Bali.validate(:co, :ce, "1234567")
iex> Bali.validate(:co, :ce, "12345678")
{:error, "CE inválida"}
iex> Bali.validate(:co, :nit, "123456-1")
Expand Down
2 changes: 1 addition & 1 deletion lib/validators/colombia.ex
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ defmodule Bali.Validators.Colombia do
# Su estructura es un bloque de 6 dígitos
@spec ce() :: Regex.t()
defp ce do
~r/^\d{6}$/
~r/^\d{6,7}$/
end

# Expresión regular para validar una NIT
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Bali.MixProject do
def project do
[
app: :bali,
version: "0.4.0",
version: "0.4.1",
description: "Validate personal and tax identifiers for mx, co, es, pt, it, br",
elixir: "~> 1.9",
start_permanent: Mix.env() == :prod,
Expand Down
2 changes: 1 addition & 1 deletion test/bali_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ defmodule BaliTest do
end

test "Puedo validar que el identificador CE(Cédula de Extranjería) de Colombia no es correcto" do
value = "1234567"
value = "12345678"
assert {:error, "CE inválida"} == Bali.validate(:co, :ce, value)
end

Expand Down
7 changes: 6 additions & 1 deletion test/validators/colombia_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,13 @@ defmodule Validators.ColombiaTest do
assert {:ok, value} == Colombia.validate(:ce, value)
end

test "Puedo verificar que la CE es inválida a 7 dígitos" do
test "Puedo validar que la CE es correcta a 7 dígitos" do
value = "1234567"
assert {:ok, value} == Colombia.validate(:ce, value)
end

test "Puedo verificar que la CE es inválida a 8 dígitos" do
value = "12345678"
assert {:error, "CE inválida"} == Colombia.validate(:ce, value)
end

Expand Down

0 comments on commit 5a01161

Please sign in to comment.