Represents a currency code following ISO 4217 standard.

Currency instances are created from the CountryRegistry which provides comprehensive currency information including symbols and decimal places.

const usd = Currency.USD;
const eur = Currency.EUR;
const mxn = Currency.fromCode('MXN');

Hierarchy (View Summary)

Accessors

Methods

  • Compares this Value Object with another for equality. Value Objects are equal if they are of the same type and all equality components match.

    Parameters

    • other: ValueObject

      The other Value Object to compare with

    Returns boolean

    true if the Value Objects are equal, false otherwise

  • Creates a Currency instance from a currency code. Uses data from CountryRegistry to populate currency information.

    Parameters

    • code: string

      The ISO 4217 currency code (e.g., "USD", "EUR")

    Returns undefined | Currency

    Currency instance or undefined if not found

    const currency = Currency.fromCode('MXN');
    console.log(currency?.name); // "Mexican Peso"
    console.log(currency?.symbol); // "$"
  • Gets all countries that use this currency.

    Returns CountryInfo[]

    Array of country information

    const euro = Currency.EUR;
    const euroCountries = euro.getCountries();
    console.log(euroCountries.length); // 19+ countries
  • Checks if this is a major world currency. Major currencies are those widely used in international trade and finance.

    Returns boolean

    true if this is a major currency

Properties

code: string
name: string
symbol: string
decimalPlaces: number