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

    Function isMacklinSearchResult

    • Validates if data matches the Macklin search result format. Search results contain a list of products and a total count. The list property is generic to support different product types.

      Type Parameters

      • T

      Parameters

      • data: unknown

        The data to validate

      Returns data is MacklinSearchResult<T>

      True if the data matches the search result format

      const response = await fetch('/api/item/search');
      if (isMacklinSearchResult(response.data)) {
      // TypeScript now knows response.data has list and total
      console.log(response.data.total);
      }
      export function isMacklinSearchResult<T>(data: unknown): data is MacklinSearchResult<T> {
      return v.safeParse(macklinSearchResultSchema, data).success;
      }