From 6339f9aa7cbb220c3cc4172206f4ad952341c6b7 Mon Sep 17 00:00:00 2001 From: CevaMenelao Date: Wed, 8 Nov 2023 17:21:10 -0600 Subject: [PATCH 1/4] Support for 7 digit as valid CE 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 --- lib/bali.ex | 2 +- lib/validators/colombia.ex | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/bali.ex b/lib/bali.ex index 61e7307..e710641 100644 --- a/lib/bali.ex +++ b/lib/bali.ex @@ -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") diff --git a/lib/validators/colombia.ex b/lib/validators/colombia.ex index 35ebe2d..59b758c 100644 --- a/lib/validators/colombia.ex +++ b/lib/validators/colombia.ex @@ -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 From 0c2e2fe95ab4fef33d55332b255d2c6e4bcc6923 Mon Sep 17 00:00:00 2001 From: CevaMenelao Date: Wed, 8 Nov 2023 17:21:34 -0600 Subject: [PATCH 2/4] Add tests for 7 and 8 digits --- test/bali_test.exs | 2 +- test/validators/colombia_test.exs | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/test/bali_test.exs b/test/bali_test.exs index 9a1e741..8be9931 100644 --- a/test/bali_test.exs +++ b/test/bali_test.exs @@ -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 diff --git a/test/validators/colombia_test.exs b/test/validators/colombia_test.exs index ea7cc28..d999dee 100644 --- a/test/validators/colombia_test.exs +++ b/test/validators/colombia_test.exs @@ -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 From 9ee6ce5df5495139790c745609ce06ebcd24b637 Mon Sep 17 00:00:00 2001 From: CevaMenelao Date: Wed, 8 Nov 2023 17:22:33 -0600 Subject: [PATCH 3/4] Bump version 0.4.1 --- mix.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mix.exs b/mix.exs index 9bd0cc3..136b07c 100644 --- a/mix.exs +++ b/mix.exs @@ -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, From f0d6b51c21ddce27c3ec8e4176f20f8c76eedd3e Mon Sep 17 00:00:00 2001 From: CevaMenelao Date: Wed, 8 Nov 2023 17:22:59 -0600 Subject: [PATCH 4/4] Format document --- test/validators/colombia_test.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/validators/colombia_test.exs b/test/validators/colombia_test.exs index d999dee..7ed7b5a 100644 --- a/test/validators/colombia_test.exs +++ b/test/validators/colombia_test.exs @@ -38,7 +38,7 @@ defmodule Validators.ColombiaTest do assert {:ok, value} == Colombia.validate(:ce, value) end - test "Puedo validar que la CE es correcta 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