Response object to validate
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;
}
Validates that a response matches the ProductResponse interface structure.