Creates a shape that allows an object property to be missing.
import {optionalShape, checkValidShape, defineShape} from 'object-shape-tester';const myShape = defineShape({ a: '', b: optionalShape(-1),});checkValidShape({a: 'hi', b: 0}, myShape); // `true`checkValidShape({a: 'hi'}, myShape); // `true`checkValidShape({b: 0}, myShape); // `false` Copy
import {optionalShape, checkValidShape, defineShape} from 'object-shape-tester';const myShape = defineShape({ a: '', b: optionalShape(-1),});checkValidShape({a: 'hi', b: 0}, myShape); // `true`checkValidShape({a: 'hi'}, myShape); // `true`checkValidShape({b: 0}, myShape); // `false`
Creates a shape that allows an object property to be missing.