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

    Function isAmbeedGetSearchProductAndRecommendedProductsByCASResponse

    • Type guard to validate if data matches the Ambeed "get search product and recommended products by CAS" API response structure. Checks the AmbeedResponseBase fields plus a value object containing the CAS-matched search_pro_dict and the r_pro_list array of recommendations.

      Parameters

      • data: unknown

        The response data to validate

      Returns data is AmbeedGetSearchProductAndRecommendedProductsByCASResponse

      Type predicate indicating if the data is a valid AmbeedGetSearchProductAndRecommendedProductsByCASResponse

      if (isAmbeedGetSearchProductAndRecommendedProductsByCASResponse(response)) {
      console.log("Matched product:", response.value.search_pro_dict.p_name_en);
      console.log("Recommendations:", response.value.r_pro_list.length);
      }
      export function isAmbeedGetSearchProductAndRecommendedProductsByCASResponse(
      data: unknown,
      ): data is AmbeedGetSearchProductAndRecommendedProductsByCASResponse {
      return v.safeParse(ambeedGetSearchProductAndRecommendedProductsByCASResponseSchema, data).success;
      }