Cast function used to return error when currency is nil
frahugo opened this issue · comments
Hugo Frappier commented
Upgraded to version 1.6 and a condition is not handled in the money_sql code:
iex(1) > Money.Ecto.Composite.Type.cast(%{amount: "10", currency: nil})
** (CondClauseError) no cond clause evaluated to a truthy value
(digital_token 0.4.0) lib/digital_token.ex:142: DigitalToken.validate_token/1
(ex_money 5.12.0) lib/money.ex:2280: Money.do_validate_currency/2
(ex_money 5.12.0) lib/money.ex:211: Money.new/3
(ex_money_sql 1.6.0) lib/money/ecto/money_ecto_composite_type.ex:96: Money.Ecto.Composite.Type.cast/2
Prior to 1.6, it was returning:
iex(1) > Money.Ecto.Composite.Type.cast(%{amount: "10", currency: nil})
{:error, [message: "The currency nil is invalid"]}
Kip Cole commented
Thanks for the report and apolgies for the regression. As of commit 070b4c I believe the issue is fixed.
I have published ex_money_sql version 1.7.1 with the fix.
Thanks again for the report.
Hugo Frappier commented
Thanks for the fix!