object-shape-tester - v5.3.0
    Preparing search index...

    Function assertValidShape

    • Assets that a variable matches the given shape.

      Type Parameters

      Parameters

      Returns asserts subject is Shape["runtimeType"]

      import {defineShape, assertValidShape} from 'object-shape-tester';

      const myShape = defineShape({
      a: '',
      });

      assertValidShape({a: 'hi'}, myShape); // succeeds
      assertValidShape({a: 'hi', b: 'bye'}, myShape, {allowExtraKeys: true}); // succeeds
      assertValidShape({a: 3, myShape}); // fails

      ShapeMismatchError If there is a mismatch