CLI and library for validating JSON data against TypeScript static type declarations.
NPM:
npm install -D intf-matchYarn:
yarn add -D intf-matchYou can add a script entry in your package.json file
with a shortcut command, which validates a dump JSON file.
Alternatively, you can install the CLI globally to execute it from anywhere.
-
Suppose, you have dumped the server response to
mock/cart-data.json. -
The data schema is described in your TypeScript modules under
src/model. Also, some types are declared insrc/common.ts -
The interface that describes the data root is
WorkingOrderPostData.
Thus, your command is:
intf-match mock/cart-data.json "src/model/index.ts,src/common.ts" WorkingOrderPostData