ChemPal Documentation - v0.0.13-beta.5
    Preparing search index...

    Function isValidProductResponse

    • Validates that a response matches the ProductResponse interface structure.

      Parameters

      • obj: unknown

        Response object to validate

      Returns obj is CarolinaProductResponse

      Type predicate indicating if object is a valid ProductResponse

      const response = await this.httpGetJson({
      path: `/api/rest/cb/product/product-details/${productId}`
      });
      if (isValidProductResponse(response)) {
      // Process valid product response
      console.log(response.product.name);
      }
      export function isValidProductResponse(obj: unknown): obj is CarolinaProductResponse {
      return validProductResponseSchema.safeParse(obj).success;
      }