Breaking Change
Money.parse/2
until this release supported the :currency_filter
option. It allowed for currencies to be filtered based upon their attributes (:all
, :current
, :historic
, :tender
, :annotated
). When multiple attributes were passed in a list, a currency had to meet all of these attributes. From this release onwards, multiple attributes items are or
ed, not and
ed. It is expected this option is used extremely rarely and therefore of limited impact.
Enhancements
Money.parse/2
now includes the option :default_currency
which allows for parsing a number only (without a currency code) and it will be tagged with the :default_currency
.
iex> Money.parse("100")
{:error,
{Money.Invalid,
"A currency code, symbol or description must be specified but was not found in \"100\""}}
iex> Money.parse("100", default_currency: :USD)
#Money<:USD, 100>
- Add
:only
and :except
options to Money.parse/2
to specify which currency codes or currency attributes are permitted. :only
and :except
replace the option :currency_filter
which is now deprecated. If provided, :currency_filter
is interpreted as :only
. An example:
iex> Money.parse("100 usd", only: :current, except: :USD)
{:error,
{Money.UnknownCurrencyError,
"The currency \"usd\" is unknown or not supported"}}
Money.parse/2
now supports negative money amounts.
iex> Money.parse("chf -100")
#Money<:CHF, -100>
iex> Money.parse("(chf 100)")
#Money<:CHF, -100>