Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for 7 digit as valid CE #17

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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