The object to validate
Type predicate indicating if the object is a valid ShopifyVariantNode
const variant = {
title: "Default Title",
sku: "GTK-001",
barcode: "",
price: { amount: "14.99" },
weight: 3.0,
weightUnit: "OUNCES",
requiresShipping: true,
availableForSale: true,
currentlyNotInStock: false
};
if (isShopifyVariantNode(variant)) {
console.log("Valid variant:", variant.sku);
}
export function isShopifyVariantNode(variant: unknown): variant is ShopifyVariantNode {
return shopifyVariantNodeSchema.safeParse(variant).success;
}
Type guard to validate if an object is a valid Shopify variant node. Checks for the presence and correct types of all required variant properties including title, SKU, price, weight, and availability fields.