@webdeveric/utils
    Preparing search index...
    • Create a type predicate function that checks if input is an object matching the given objectShape. Set additionalProperties to false to reject objects with extra properties.

      Type Parameters

      Parameters

      • objectShape: Shape
      • additionalProperties: boolean = true

      Returns TypePredicateFn<
          {
              [Property in string
              | number
              | symbol]: (Type & InferTypeFromShape<Shape>)[Property]
          },
      >

      const isPerson = shape({ name: isString, age: isNumber });
      isPerson({ name: 'Andy', age: 30 }); // true
      isPerson({ name: 'Andy' }); // false

      const isStrictPerson = shape({ name: isString, age: isNumber }, false);
      isStrictPerson({ name: 'Andy', age: 30, extra: true }); // false