ChemPal Documentation - v1.6.0
    Preparing search index...
    • 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.

      Parameters

      • variant: unknown

        The object to validate

      Returns variant is ShopifyVariantNode

      Type predicate indicating if the object is a valid ShopifyVariantNode

      const variant = {
      id: "gid://shopify/ProductVariant/123",
      title: "Default Title",
      sku: "GTK-001",
      availableForSale: true,
      weight: 3.0,
      weightUnit: "OUNCES",
      price: { amount: "14.99" }
      };

      if (isShopifyVariantNode(variant)) {
      console.log("Valid variant:", variant.sku);
      }
      export function isShopifyVariantNode(variant: unknown): variant is ShopifyVariantNode {
      return v.safeParse(shopifyVariantNodeSchema, variant).success;
      }