The value to validate (typically a parsed JSON response)
Type predicate indicating whether product is a valid product detail
const data = await this.httpGetJson({ host: this.apiHost, path: "/api/v2/products/geraniol-60" });
if (isProductDetail(data)) console.log(data.variants?.length);
export function isProductDetail(product: unknown): product is MySimpleStoreProductDetail {
return v.safeParse(mySimpleStoreProductDetailSchema, product).success;
}
Type guard validating that a value matches the MySimpleStore product-detail response: an object with id/slug/name and an optional
variantsarray. The per-variant shape is guarded at the point of use so a stray entry can't reject the whole response.