The response data to validate
Type predicate indicating if the data is a valid AmbeedProductPriceResponse
const response = await this.httpPostJson({ path: "/webapi/v1/product_price" });
if (isAmbeedProductPriceResponse(response)) {
console.log("Product:", response.value.proInfo.p_name_en);
console.log("Lead time:", response.value.proInfo.p_leadtime);
}
export function isAmbeedProductPriceResponse(data: unknown): data is AmbeedProductPriceResponse {
return v.safeParse(ambeedProductPriceResponseSchema, data).success;
}
Type guard to validate if data matches the Ambeed product price API response structure. Checks the
AmbeedResponseBasefields plus avalue.proInfoobject, which carries the shared product info every priced variant in the response is keyed against.