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).
npm install object-shape-testerVerified import paths — ran on the pinned version, not inferred.
This example demonstrates defining an object shape, deriving a TypeScript type and a default value, and then validating an object against that shape.
Review error handling logic and remove any reliance on the `value` property of `ShapeMismatchError` instances.
Upgrade your Node.js environment to version 22 or later. Using a Node.js version manager like `nvm` is recommended.
Ensure your project is configured for ES Modules or use a bundler that correctly handles ES Modules for CommonJS output.
Ensure your `package.json` contains `"type": "module"` or change your file extension to `.mjs`. Alternatively, configure your build system to transpile ES Modules.
Inspect the full `ShapeMismatchError` message for details on the path and specific mismatch. Adjust the input object to match the `defineShape` definition.
No dependency data recorded yet.