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

    Function assertWrapValidShape

    • Assets that a variable matches the given shape and then returns the variable.

      Type Parameters

      Parameters

      Returns Shape["runtimeType"]

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

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

      assertValidShape({a: 'hi'}, myShape); // returns `{a: 'hi'}`
      assertValidShape({a: 'hi', b: 'bye'}, myShape, {allowExtraKeys: true}); // returns `{a: 'hi', b: 'bye'}`
      assertValidShape({a: 3, myShape}); // throws an error

      ShapeMismatchError If there is a mismatch