elixirmoney / money

Elixir library for working with Money safer, easier, and fun... Is an interpretation of the Fowler's Money pattern in fun.prog.
https://hex.pm/packages/money/
MIT License
827 stars 141 forks source link

Add support for value of money to cast when field type is `Money.Ecto.Map.Type` #205

Open uzairaslam196 opened 1 year ago

uzairaslam196 commented 1 year ago

I am currently working on an Elixir project with multiple currencies; I need currency code with the amount from form input to cast directly using changeset. However, I discovered that form sends money in a string format similar to this "$99", which cannot be cast by the Money.Ecto.Map.Type type as it expects map. So, I believe it should send the value as a map, similar to this %{"amount" => 99, "currency" => "USD"} so that it can be easily cast by changeset when the type is Money.Ecto.Map.Type.

Same issue happens when we use Money.Ecto.Map.Type

Currently, I have to update form input values explicitly into map to cast them in changeset.