Compares this Value Object with another for equality. Value Objects are equal if they are of the same type and all equality components match.
The other Value Object to compare with
true if the Value Objects are equal, false otherwise
StaticcreateCreates a Money instance with validation.
The monetary amount
The currency
Success with Money or Failure with DomainError
StaticCLPCreates a Money instance in Chilean Pesos.
The amount in Chilean Pesos
A Money instance
StaticCOPCreates a Money instance in Colombian Pesos.
The amount in Colombian Pesos.
A Money instance
StaticPENCreates a Money instance in Peruvian Sol.
The amount in Peruvian Sol.
A Money instance
StaticARSCreates a Money instance in Argentine Pesos.
The amount in Argentine Pesos
A Money instance
StaticfromCreates a Money instance from a currency code.
The monetary amount
The ISO 4217 currency code
Success with Money or Failure with DomainError
StaticUSDCreates a Money instance in US Dollars.
The amount in USD
A Money instance
StaticEURCreates a Money instance in Euros.
The amount in EUR
A Money instance
StaticGBPCreates a Money instance in British Pounds.
The amount in GBP
A Money instance
StaticJPYCreates a Money instance in Japanese Yen.
The amount in JPY
A Money instance
Adds another Money amount to this one. Both Money objects must have the same currency.
The Money to add
Success with new Money or Failure with DomainError
Subtracts another Money amount from this one. Both Money objects must have the same currency. Result cannot be negative.
The Money to subtract
Success with new Money or Failure with DomainError
Multiplies this Money by a factor.
The multiplication factor
A new Money instance
Divides this Money by a divisor.
The division divisor
Success with new Money or Failure with DomainError
Checks if this Money is greater than another.
The Money to compare with
true if this Money is greater
Checks if this Money is less than another.
The Money to compare with
true if this Money is less
Formats this Money as a string according to the locale.
The locale to use for formatting (default: 'en-US')
A formatted string representation
Gets all countries that use this money's currency.
Array of country information
Checks if this money's currency is used in a specific country.
The ISO2 country code
true if the currency is used in the country
ProtectedgetReturns the components that determine equality for this Value Object. Two Value Objects are equal if all their equality components are equal.
An array of values used for equality comparison
Represents a monetary amount with a specific currency.
Money is immutable and all operations return new Money instances. Operations between Money objects with different currencies will fail.
Example