AshMoney.Types.Money (ash_money v0.2.3)

View Source

A money type for Ash that uses the ex_money library.

When constructing a composite type, use a tuple in the following structure:

composite_type(%{currency: "USD", amount: Decimal.new("0")}}, AshMoney.Types.Money)

If you've added a custom type, like :money:

composite_type(%{currency: "USD", amount: Decimal.new("0")}, :money)

Constraints Options

Example

attribute :charge, :money do
  constraints: [
    ex_money_opts: [
      no_fraction_if_integer: true,
      format: :short
    ]
  ]
end

Summary

Functions

handle_change?()

prepare_change?()