Check if a variable matches the given shape.
true or false
true
false
import {defineShape, isValidShape} from 'object-shape-tester';const myShape = defineShape({ a: '',});isValidShape(myShape, {a: 'hi'}); // `true`isValidShape(myShape, {a: 3}); // `false`isValidShape(myShape, {a: 'hi', b: 'bye'}, {allowExtraKeys: true}); // `true` Copy
import {defineShape, isValidShape} from 'object-shape-tester';const myShape = defineShape({ a: '',});isValidShape(myShape, {a: 'hi'}); // `true`isValidShape(myShape, {a: 3}); // `false`isValidShape(myShape, {a: 'hi', b: 'bye'}, {allowExtraKeys: true}); // `true`
Check if a variable matches the given shape.