The data to validate
True if the data matches the product details response format
const response = await fetch("/api/product/list?code=B803083");
const data = await response.json();
if (isMacklinProductDetailsResponse(data.data)) {
console.log("Products:", data.data.list.length);
}
export function isMacklinProductDetailsResponse(
data: unknown,
): data is MacklinProductDetailsResponse {
if (typeof data !== 'object' || data === null) return false;
if (!('list' in data) || !Array.isArray(data.list)) return false;
return data.list.every(isMacklinProductDetails);
}
Validates if data matches the Macklin product details response format. Product details response contains a list of product details.