object-shape-tester - v6.9.2
    Preparing search index...

    Function unionShape

    • Creates a shape that requires an of the given possible values.

      Type Parameters

      • T extends readonly [any, any]

      Parameters

      • ...inits: T

      Returns Shape<TUnion<ShapeInitSchema<ArrayElement<T>>[]>>

      import {unionShape, checkValidShape} from 'object-shape-tester';

      const myShape = unionShape('', -1);

      checkValidShape('a', myShape); // `true`
      checkValidShape(10, myShape); // `true`
      checkValidShape({}, myShape); // `false`