ChemPare Documentation - v0.0.0
    Preparing search index...

    Function checkObjectStructure

    • Check object structure when provided an obeject and similar structure with variable types as the values

      Parameters

      • data: unknown

        The value to validate

      • requiredProps: Record<string, string>

        The required properties and their expected types

      Returns boolean

      Type predicate indicating if the value has minimal required product properties

      if ( ! checkObjectStructure(data, {
      title: "string",
      price: "number",
      quantity: "number"
      })) {
      throw new Error("data is not complete - " + JSON.stringify(data));
      }