The value to validate (typically a parsed JSON response)
Type predicate indicating whether response is a valid search response
const data = await this.httpGetJson({ host: this.apiHost, path: "/api/v2/products" });
if (isValidSearchResponse(data)) {
for (const product of data.products) console.log(product.name);
}
export function isValidSearchResponse(response: unknown): response is MySimpleStoreSearchResponse {
return v.safeParse(mySimpleStoreSearchResponseSchema, response).success;
}
Type guard validating that a value matches the MySimpleStore search/list response envelope: an object with a
productsarray whose items each carry the minimal id/slug/name/relative_url fields the supplier reads.