Generates JSON Schema validators from TypeScript type definitions. Current version 6.0.1 ships ajv-based runtime validators that ensure type safety at runtime. Maintained actively with watch mode, caching, and custom code generation support. Differs from ts-json-schema-generator or typebox by producing standalone validator files alongside your types, enforcing single source of truth.
npm install create-validator-tsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Install package and peer dependency ajv, define TypeScript types, run CLI generator, then import and use generated validator function.
Catch errors and access the `errors` property; consider using custom generator to throw more detailed errors.
Ensure all types used in validation are exported from the source file.
To catch extra properties, modify generated code or use custom generator to change ajv options.
Use glob pattern: `create-validator-ts "src/**/api-types.ts"` instead of listing files.
Review generated code manually; consider submitting PR to remove these flags.
Use named import: `import { validateMyType } from './types.validator';`
Check exact function name in generated file.Catch error and log `error.errors` if available, or modify custom generator to add Ajv error details.
Install ajv: `npm install ajv` or `yarn add ajv`.
Verify pattern matches your TypeScript files: `ls src/**/api-types.ts` Use `--cwd` option if needed.
Use `npx create-validator-ts` or install globally: `npm install -g create-validator-ts`.