The response data to validate
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;
}
Type guard to validate if data matches the Ambeed "get search product and recommended products by CAS" API response structure. Checks the
AmbeedResponseBasefields plus avalueobject containing the CAS-matchedsearch_pro_dictand ther_pro_listarray of recommendations.