Skip to content

Commit

Permalink
Added the shortcode option to normalize/2 (#3)
Browse files Browse the repository at this point in the history
- shortcodes passed to Numerus.Formatter.normalize/2 will always
  return itself as the result without error.
- Bump version to 0.1.3
  • Loading branch information
pramsky authored Feb 18, 2023
1 parent 6a57055 commit 982dff8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions lib/numerus/formatter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ defmodule Numerus.Formatter do

@doc """
Normalize the did into the supplied normalization format. If no format is
provided when called, @normal_format is used.
provided when called, @normal_format is used. Shortcodes passed to the
converter will always return the shortcode as-is.
Example:
```elixir
Expand All @@ -52,11 +53,12 @@ defmodule Numerus.Formatter do
@spec normalize(did :: bitstring, format :: atom() | nil) :: bitstring() | {:error, :invalid_format}
def normalize(did, format) do
case format do
:e164 -> to_e164(did)
:npan -> to_npan(did)
:one_npan -> to_1npan(did)
:us_intl -> to_usintl(did)
_ -> {:error, :invalid_format}
:e164 -> to_e164(did)
:npan -> to_npan(did)
:one_npan -> to_1npan(did)
:us_intl -> to_usintl(did)
:shortcode -> did
_ -> {:error, :invalid_format}
end
end

Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ defmodule Numerus.MixProject do
def project do
[
app: :numerus,
version: "0.1.2",
version: "0.1.3",
elixir: "~> 1.14",
start_permanent: Mix.env() == :prod,
deps: deps(),
Expand Down

0 comments on commit 982dff8

Please sign in to comment.