JSON schema validator with excellent type inference for JavaScript and TypeScript. Current stable version is 5.0.3. It provides a declarative API using an underscore (_) namespace for defining schemas with built-in validators like string, number, boolean, union, record, list, etc. Differentiators include automatic TypeScript type inference via the produce method, detailed error objects that mirror the schema shape, and a lightweight bundle (minzipped size shown in badge). The library is actively maintained, supports Node.js >=10, and is ESM and CJS compatible.
npm install tiny-schema-validatorNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a Person schema, then demonstrates is(), validate(), and produce() methods.
For optional fields, define a separate schema and embed it: const OptionalName = createSchema({ name: _.string() }).embed({ optional: true }).Update code to check the return value of validate() instead of using try/catch.
Use `_.list([_.string(), _.number()])` for a tuple [string, number].
Use `_.record` or `_.list` for object/array constants.
Change import to: import { createSchema } from 'tiny-schema-validator'Change import to: import { _ } from 'tiny-schema-validator'Use: type PersonType = ReturnType<typeof Person.produce>
No dependency data recorded yet.