github.com/whiteand/ts-quartet

Typescript version of quartet

Open this visualization on its own page →

Contributors

5

Lines of Code

1,713

From

2019-05-15

To

2020-11-19

About whiteand/ts-quartet

Quartet 11 is a lightweight TypeScript data validation library that compiles declarative schemas into fast validation functions. At just 6.76 KB minified and gzipped with no dependencies, it offers a straightforward approach to validating JavaScript values against type definitions.

The library uses a declarative syntax where primitive values serve as their own schemas, and objects define validation rules through their structure. Users can compose complex validators by combining built-in schemas like `v.string`, `v.number`, and `v.arrayOf()` with custom logic via methods like `v.and()`, `v.custom()`, and `v.not()`. Special features include support for object rest patterns to validate dynamic properties, pair schemas for validating array elements with their indices, and optional explanations that detail exactly where validation failed and why.

Performance is a key strength—benchmarks show Quartet 11 validates nearly three times faster than Ajv, a popular JSON schema validator. The library serves developers building APIs, validating third-party responses, or ensuring type safety at runtime, particularly in projects where bundle size and validation speed matter.

Share this video