From 9d8031e0d6b3e323669653a76e7e4f3532e011be Mon Sep 17 00:00:00 2001 From: Paolo Montrasio Date: Tue, 6 Apr 2021 09:51:35 +0200 Subject: [PATCH 1/3] Replace the deprecated String.strip/1 with String.trim/1 --- lib/exiban.ex | 4 ++-- lib/exiban/parser.ex | 2 +- mix.lock | 10 ++++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/exiban.ex b/lib/exiban.ex index 642077c..8495b47 100644 --- a/lib/exiban.ex +++ b/lib/exiban.ex @@ -94,7 +94,7 @@ defmodule ExIban do {_, _, _, _, formatted} = parse(iban) formatted |> String.replace(~r/(.{4})/, "\\1 ") - |> String.strip + |> String.trim end @doc """ @@ -110,7 +110,7 @@ defmodule ExIban do def format_compact(iban) do {_, _, _, _, formatted} = parse(iban) formatted - |> String.strip + |> String.trim end defp prepare_output({[], _}), do: :ok diff --git a/lib/exiban/parser.ex b/lib/exiban/parser.ex index 6c80b19..fe823b9 100644 --- a/lib/exiban/parser.ex +++ b/lib/exiban/parser.ex @@ -29,7 +29,7 @@ defmodule ExIban.Parser do defp normalize(iban) do iban |> String.replace(~r/\s+/, "") - |> String.strip + |> String.trim |> String.upcase end end diff --git a/mix.lock b/mix.lock index 8c4bdb2..2b75ebd 100644 --- a/mix.lock +++ b/mix.lock @@ -1,4 +1,6 @@ -%{"dogma": {:hex, :dogma, "0.1.0"}, - "earmark": {:hex, :earmark, "0.2.1"}, - "ex_doc": {:hex, :ex_doc, "0.11.4"}, - "poison": {:hex, :poison, "1.5.2"}} +%{ + "dogma": {:hex, :dogma, "0.1.0"}, + "earmark": {:hex, :earmark, "0.2.1", "ba6d26ceb16106d069b289df66751734802777a3cbb6787026dd800ffeb850f3", [:mix], [], "hexpm", "c86afb8d22a5aa8315afd4257c7512011c0c9a48b0fea43af7612836b958098b"}, + "ex_doc": {:hex, :ex_doc, "0.11.4", "a064bdb720594c3745b94709b17ffb834fd858b4e0c1f48f37c0d92700759e02", [:mix], [{:earmark, "~> 0.1.17 or ~> 0.2", [hex: :earmark, repo: "hexpm", optional: true]}], "hexpm", "639e97b24c1c6c172f557163b830673646983417de9ac0da2c25c7063deed293"}, + "poison": {:hex, :poison, "1.5.2"}, +} From ade3e31349743170375cec42683770c2c70aec6f Mon Sep 17 00:00:00 2001 From: Paolo Montrasio Date: Tue, 6 Apr 2021 09:52:12 +0200 Subject: [PATCH 2/3] Replace the deprecated String.to_char_list/1 with String.to_charlist/1 --- lib/exiban/validators.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/exiban/validators.ex b/lib/exiban/validators.ex index 78cc154..7f7f1fc 100644 --- a/lib/exiban/validators.ex +++ b/lib/exiban/validators.ex @@ -82,7 +82,7 @@ defmodule ExIban.Validators do defp check_digits({errors, {country_code, check_digits, bban, _, _} = parsed_iban}) do - chars = String.to_char_list(bban <> country_code <> check_digits) + chars = String.to_charlist(bban <> country_code <> check_digits) numbers = for byte <- chars, into: [] do case byte do byte when byte in 48..57 -> List.to_string([byte]) From 00ca22275073d3616af613cc63a6571772ed3fd2 Mon Sep 17 00:00:00 2001 From: Paolo Montrasio Date: Tue, 6 Apr 2021 09:53:43 +0200 Subject: [PATCH 3/3] Fix the warnings about rules does not exist --- lib/exiban/validators.ex | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/exiban/validators.ex b/lib/exiban/validators.ex index 7f7f1fc..39c4544 100644 --- a/lib/exiban/validators.ex +++ b/lib/exiban/validators.ex @@ -3,7 +3,6 @@ defmodule ExIban.Validators do Set of validation rules to perform on checking IBAN account number. """ - import ExIban.Rules import ExIban.Parser @doc """ @@ -53,7 +52,7 @@ defmodule ExIban.Validators do defp check_country_code({errors, {country_code, _, _, _, _} = parsed_iban}) do cond do - rules |> Map.get(country_code) |> is_nil -> + ExIban.Rules.rules |> Map.get(country_code) |> is_nil -> {errors ++ [:unknown_country_code], parsed_iban} true -> {errors, parsed_iban} end @@ -62,7 +61,7 @@ defmodule ExIban.Validators do defp check_length({errors, {country_code, _, _, iban_length, _} = parsed_iban}) do cond do - rules |> Map.get(country_code, %{}) |> Map.get("length") != iban_length -> + ExIban.Rules.rules |> Map.get(country_code, %{}) |> Map.get("length") != iban_length -> {errors ++ [:bad_length], parsed_iban} true -> {errors, parsed_iban} end @@ -70,7 +69,7 @@ defmodule ExIban.Validators do defp check_format({errors, {country_code, _, bban, _, _} = parsed_iban}) do - {:ok, reg} = rules + {:ok, reg} = ExIban.Rules.rules |> Map.get(country_code, %{}) |> Map.get("bban_pattern", "") |> Regex.compile