getCurrencyCode()function
getCurrencyCode(value: string): CurrencyCode | undefined
| Param | Type | |
|---|---|---|
value | string | The string to normalise and check. required |
| Return | |
|---|---|
CurrencyCode | undefined | The normalised CurrencyCode, or undefined if the value isn't a supported currency. |
Normalise a value to a valid ISO 4217 CurrencyCode, or undefined if it isn't a supported currency.
- Upper-cases and trims the input before checking it against
CURRENCY_CODES.
Examples
getCurrencyCode("gbp") // "GBP"getCurrencyCode("nope") // undefined