Allow get_currencies_for_select to accept a new parameter that filters allowed currencies
vraravam opened this issue · 2 comments
In my app, I need to only allow certain currencies that are allowed for the user to choose from. I would like the get_currencies_for_select
and get_currencies
functions to accept an optional parameter, which can be a function that can be used to filter acceptable currencies.
For eg, the way I am currently doing this is:
Enum.filter(CurrencyFormatter.get_currencies_for_select(:names), fn {k, _} -> k =~ ~r/inr|usd|eur/i end)
instead, if the function can be passed into the get_currencies_for_select
- that would be ideal.
Hi @vraravam ,
I've just updated and published version 0.4.4 which contains an option to enable a whitelist for the currencies. You can enable this by updating your app's config using
config :currency_formatter, :whitelist, ["EUR", "GBP", "USD"]
Hope this helps you out, and thanks for the suggestion :D
Gerard.
Thanks - works like a charm! Only issue now is that your library asks for poisson v3.0.0 - while my codebase is using the older version, so, I have overridden in mix.exs
- hopefully nothing breaks