ChemPal Documentation - v1.6.0
    Preparing search index...
    • 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 v.safeParse(validProductResponseSchema, obj).success;
      }