Money. Input
(Money.Input v0.1.0)
View Source
Locale-aware money form input.
This package ships:
Headless —
Money.Input.Cast,Money.Input.Validator,Money.Input.Currency. Pure Elixir, no Phoenix dependency. User-typed strings are parsed byMoney.parse/2; money formatting isMoney.to_string/2directly — there are no wrappers here.Ecto —
Money.Input.Changeset(compiled when:ectois loaded).HEEx components —
Money.Input.Components(compiled when:phoenix_live_viewis loaded). Ships<.money_input>and<.currency_picker>plus an AutoNumeric-backed JS hook inpriv/static/money_input.js.Visualizer —
Money.Input.Visualizer(compiled when:plugis loaded) for local development. Behind a config flag — see that module.
For plain number inputs (no currency), see the sibling
localize_inputs
package — <.number_input> lives there.
Quick examples
iex> {:ok, money} = Money.Input.Cast.cast(
...> %{"amount" => "1.234,56", "currency" => "EUR"},
...> locale: :de
...> )
iex> Money.to_string!(money, locale: :de)
"1.234,56 €"
iex> Money.to_string!(Money.new(:USD, "1234.56"), locale: :en)
"$1,234.56"
iex> Money.to_string!(Money.new(:EUR, "1234.56"), locale: :de, currency_symbol: :none)
"1.234,56"
Summary
Functions
@spec version() :: String.t()
Returns the installed package version as a string.
Returns
- The version string declared in
mix.exs.
Examples
iex> Money.Input.version() |> Version.parse!()
iex> :ok
:ok