ChemPal Documentation - v1.6.0
    Preparing search index...

    Function isProductItem

    • Type guard to validate if an object is a valid Wix ProductItem. Checks for the presence and correct types of all required item properties including ID, price, and ensures optionsSelections is a non-empty array.

      Parameters

      • item: unknown

        Object to validate as ProductItem

      Returns item is ProductItem

      Type predicate indicating if item is a valid ProductItem

      // Valid product item
      const validItem = {
      id: "item_123",
      formattedPrice: "$29.99",
      price: 29.99,
      optionsSelections: [1]
      };

      if (isProductItem(validItem)) {
      console.log("Valid product item:", validItem.id);
      console.log("Price:", validItem.formattedPrice);
      }
      export function isProductItem(item: unknown): item is ProductItem {
      return v.safeParse(productItemSchema, item).success;
      }