The data to validate
True if the data matches the search result format
const response = await fetch('/api/item/search');
if (isMacklinSearchResult(response.data)) {
// TypeScript now knows response.data has list and total
console.log(response.data.total);
}
export function isMacklinSearchResult<T>(data: unknown): data is MacklinSearchResult<T> {
return v.safeParse(macklinSearchResultSchema, data).success;
}
Validates if data matches the Macklin search result format. Search results contain a list of products and a total count. The list property is generic to support different product types.