ChemPal Documentation - v0.0.13-beta.5
    Preparing search index...

    Function isShopifyVariantNode

    • 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 = {
      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;
      }