ChemPal Documentation - v0.0.13-beta.5
    Preparing search index...
    • Type guard to validate if a value is a valid currency code. Checks if the value is a string and if it is in the CURRENCY_SYMBOL_MAP.

      Parameters

      • code: unknown

        The value to validate

      Returns code is valueof<{ [key: string]: string }>

      Type predicate indicating if the value is a valid currency code

      const validCode = "USD";
      if (isCurrencyCode(validCode)) {
      console.log("Valid currency code:", validCode);
      } else {
      console.log("Invalid currency code:", validCode);
      }
      export function isCurrencyCode(code: unknown): code is CurrencyCode {
      return typeof code === "string" && Object.values(CURRENCY_SYMBOL_MAP).includes(code);
      }