ChemPal Documentation - v0.0.13-beta.5
    Preparing search index...
    • Type guard to validate if a value is a valid QuantityObject. Checks for the presence and correct types of quantity (number) and uom (string).

      Parameters

      • value: unknown

        The value to validate

      Returns value is QuantityObject

      Type predicate indicating if the value is a valid QuantityObject

      const qty = parseQuantity('100g');
      if (isQuantityObject(qty)) {
      console.log(`${qty.quantity}${qty.uom}`);
      }
      export function isQuantityObject(value: unknown): value is QuantityObject {
      return quantityObjectSchema.safeParse(value).success;
      }