SoftBank.Note.parse

You're seeing just the function parse, go back to SoftBank.Note module for more information.
Link to this function

parse(value, currency \\ nil, opts \\ [])

View Source

Specs

parse(String.t() | float(), atom() | String.t(), Keyword.t()) :: {:ok, t()}
parse(String.t() | float(), atom() | String.t(), Keyword.t()) :: t()

Parse a value into a SoftBank.Note type.

The following options are available:

  • separator - default ",", sets the separator for groups of thousands. "1,000"
  • delimeter - default ".", sets the decimal delimeter. "1.23"

Examples:

iex> SoftBank.Note.parse("$1,234.56", :USD)
{:ok, %SoftBank.Note{amount: 123456, currency: :USD}}
iex> SoftBank.Note.parse("1.234,56", :EUR, separator: ".", delimeter: ",")
{:ok, %SoftBank.Note{amount: 123456, currency: :EUR}}
iex> SoftBank.Note.parse("1.234,56", :WRONG)
:error
iex> SoftBank.Note.parse(1_234.56, :USD)
{:ok, %SoftBank.Note{amount: 123456, currency: :USD}}
iex> SoftBank.Note.parse(-1_234.56, :USD)
{:ok, %SoftBank.Note{amount: -123456, currency: :USD}}