whiteand/ts-quartet

Created May 6, 2022 · View the whiteand/ts-quartet repository page

Typescript version of quartet

Want this for your repo?

Render a free sample of any GitHub repo in seconds.

Visualize your own →

Contributors

5

Lines of Code

1,713

From

May 15, 2019

To

Nov 19, 2020

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