ChemPal Documentation - v0.0.13-beta.5
    Preparing search index...
    • Type guard to validate if a value is a valid ParsedPrice object. Checks for the presence and correct types of currencyCode, currencySymbol, and price.

      Parameters

      • data: unknown

        The value to validate

      Returns data is ParsedPrice

      Type predicate indicating if the value is a valid ParsedPrice

      const parsed = parsePrice('$1,234.56');
      if (isParsedPrice(parsed)) {
      console.log(parsed.currencyCode); // 'USD'
      }
      export function isParsedPrice(data: unknown): data is ParsedPrice {
      return parsedPriceSchema.safeParse(data).success;
      }