Creates a shape that requires matching a value within the given enum.
Optional
If omitted or undefined, the first value in the enum object will be used as the default.
undefined
import {enumShape, checkValidShape} from 'object-shape-tester';enum MyEnum { A = 'a', B = 'b',}const myShape = enumShape(MyEnum);checkValidShape(MyEnum.A, myShape); // `true`checkValidShape('a', myShape); // `true`checkValidShape('c', myShape); // `false` Copy
import {enumShape, checkValidShape} from 'object-shape-tester';enum MyEnum { A = 'a', B = 'b',}const myShape = enumShape(MyEnum);checkValidShape(MyEnum.A, myShape); // `true`checkValidShape('a', myShape); // `true`checkValidShape('c', myShape); // `false`
Creates a shape that requires matching a value within the given enum.