The value to validate
Type predicate indicating whether response is an EpagesSearchResponse
const json = await httpPostJson({ path: "/api/v2/search", body: { query: "" } });
if (isEpagesSearchResponse(json)) {
console.log(`${json.totalNumberOfProducts} products in catalog`);
}
export function isEpagesSearchResponse(response: unknown): response is EpagesSearchResponse {
return v.safeParse(epagesSearchResponseSchema, response).success;
}
Type guard for the ePages catalog search response (
POST /api/v2/search). Verifies theproductsarray (each with an id, name, and links) and thetotalNumberOfProductscount used to drive pagination.