ChemPal Documentation - v1.6.0
    Preparing search index...
    • Type guard validating that a value matches the MySimpleStore product-detail response: an object with id/slug/name and an optional variants array. The per-variant shape is guarded at the point of use so a stray entry can't reject the whole response.

      Parameters

      • product: unknown

        The value to validate (typically a parsed JSON response)

      Returns product is MySimpleStoreProductDetail

      Type predicate indicating whether product is a valid product detail

      const data = await this.httpGetJson({ host: this.apiHost, path: "/api/v2/products/geraniol-60" });
      if (isProductDetail(data)) console.log(data.variants?.length);
      export function isProductDetail(product: unknown): product is MySimpleStoreProductDetail {
      return v.safeParse(mySimpleStoreProductDetailSchema, product).success;
      }