object-shape-tester
Version:
Test object properties and value types.
22 lines (21 loc) • 578 B
JavaScript
import { Type } from '@sinclair/typebox';
import { defineShape } from '../shape/shape.js';
/**
* Creates a shape that allows any value. This should be used sparingly.
*
* @category Shape
* @example
*
* ```ts
* import {unknownShape, checkValidShape} from 'object-shape-tester';
*
* const myShape = unknownShape();
*
* checkValidShape('a', myShape); // `true`
* checkValidShape(10, myShape); // `true`
* checkValidShape({}, myShape); // `true`
* ```
*/
export function unknownShape(defaultValue) {
return defineShape(Type.Unknown({ default: defaultValue }));
}