ChemPal Documentation - v1.6.0
    Preparing search index...

    Module utils/typeGuards/productbuilder

    Functions - Typeguards

    isAvailability

    Type guard to validate if a value is a valid availability status. Checks if the value is a string that matches one of the predefined AVAILABILITY enum values. Matching is case-insensitive — input is lowercased before comparison.

    isValidVariant

    Type guard to validate if a value is a valid product variant. Checks for the presence and correct types of variant properties. A variant can be partial as it may inherit some properties from the parent product (such as uom, currency, URL, etc.).

    isProductImage

    Type guard to validate if a value is a valid product image entry. Checks for a string href and a type of either "image" or "thumbnail". The href is only shape-checked here; the builder resolves it to an absolute URL (and drops the entry when it can't).

    isCachedProductData

    Type guard for a cached product-data record — the plain object produced by ProductBuilder.dump() and round-tripped through the product-detail cache. Narrows an unknown (or Record<string, unknown>) cache read to Partial<T> so it can be handed to ProductBuilder.setData without an assertion.