The object to validate
Type predicate indicating if the object is a valid ShopifyProductNode
const product = {
id: "gid://shopify/Product/123",
title: "Gold Test Kit",
handle: "gold-test-kit",
description: "A gold testing kit",
onlineStoreUrl: "https://example.com/products/gold-test-kit",
variants: { edges: [{ node: validVariant }] }
};
if (isShopifyProductNode(product)) {
console.log("Valid product:", product.title);
}
export function isShopifyProductNode(product: unknown): product is ShopifyProductNode {
return shopifyProductNodeSchema.safeParse(product).success;
}
Type guard to validate if an object is a valid Shopify product node. Checks for the presence and correct types of all required product properties and validates that all nested variant nodes are also valid.