{"library":"object-shape-tester","title":"Runtime Object Shape Testing and Type Definition","description":"object-shape-tester is a TypeScript-first utility library designed to define, validate, and provide default values for JavaScript objects at both compile-time (via TypeScript types) and runtime. The library's current stable version is 6.11.0, with minor and patch releases occurring frequently, indicating active maintenance and development. Its core differentiator lies in generating TypeScript types, runtime validation logic, and default object values from a single, concise shape definition, reducing redundancy and ensuring consistency across an application. It supports complex type definitions through specifiers like `unionShape`, `intersectShape`, and `enumShape`, and can even integrate with `@sinclair/typebox` schemas for advanced use cases. This approach ensures that objects conform to expected structures throughout their lifecycle, suitable for both testing environments and production data processing, especially in Node.js applications (requiring Node.js >=22).","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install object-shape-tester"],"cli":null},"imports":["import { defineShape } from 'object-shape-tester';","import { assertValidShape } from 'object-shape-tester';","import { ShapeMismatchError } from 'object-shape-tester';","import { unionShape } from 'object-shape-tester';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { assertValidShape, defineShape } from 'object-shape-tester';\n\nconst userShape = defineShape({\n    /**\n     * This value is simplified to just a `string` required type, with `'empty name'` as the default\n     * value.\n     */\n    name: 'empty name',\n    /** This value is simplified to just a `number` required type, with `0` as the default value. */\n    id: 0,\n});\n\n/** Access the TypeScript type with `.runtimeType`. */\nexport type User = typeof userShape.runtimeType;\n\n/**\n * Access the default value with `.default`. For this shape, the default value is:\n *\n * `{name: 'empty name', id: 0}`\n */\nexport const emptyUser = userShape.default;\n\nconst myUser: User = {\n    name: 'my name',\n    id: 1000,\n};\n\nassertValidShape(myUser, userShape);\n\nconsole.log('User is valid:', myUser);","lang":"typescript","description":"This example demonstrates defining an object shape, deriving a TypeScript type and a default value, and then validating an object against that shape.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}