Paseri
December 22, 2024 · View on GitHub
Paseri
A TypeScript parsing and validation library for structured data. Ensure that untrusted input from users or external APIs conforms to the expected format.
Why the name? It's the Japanese name for parsley (パセリ), and also a play on words on parse/parsing, which is the goal of this library.
Installation
deno add jsr:@vbudovski/paseri
bunx jsr add @vbudovski/paseri
pnpm i jsr:@vbudovski/paseri
yarn add jsr:@vbudovski/paseri
npx jsr add @vbudovski/paseri
Acknowledgements
Zod
Paseri is heavily inspired by Zod's expressive API. While Zod is the industry standard for general-purpose validation, Paseri was built to bring that same developer experience to performance-critical applications and environments where Zod's architecture may be a bottleneck — all while maintaining a zero-compromise approach to security.
Valita
Valita sets the high water-mark for performance in the TypeScript ecosystem1. Paseri matches or exceeds this raw efficiency while offering a more expansive, Zod-like feature set, and a focus on schema immutability.
Goals
The list may be expanded over time, but for now the objectives are the following:
- Parsing and validation of untrusted input to ensure it conforms to the expected format. A successful result will be typed with the narrowest possible definition to obviate the need to do additional validation at the point of usage2.
- High performance1 and usability in a strict Content Security Policy (CSP) environment.
- An API that is reasonably close to that of Zod. One-to-one compatibility is not the intention.
- Immutability of schemas. This avoids a lot of bugs caused by mutating references to non-primitive types.
Documentation
Developer guide
Paseri uses the Deno runtime rather than Node, and requires Deno 2.7 or later. Packages are published to the JSR registry only, and publishing is performed automatically by CI.
paseri-libcontains the sources for the library.paseri-docscontains the documentation, built with Astro and Starlight.
Setup
After cloning the repository, be sure you set up the git hooks using the following command:
deno task init
Running tests
deno test -P
Running benchmarks
deno bench
Footnotes
-
While higher performance is possible using dynamic code execution (JIT) or ahead-of-time (AOT) compilation, these approaches introduce security risks or added build complexity. ↩ ↩2
-
An excellent article on the concept of type-driven design. ↩