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.
deno add jsr:@vbudovski/paseri
bunx jsr add @vbudovski/paseri
pnpx jsr add @vbudovski/paseri
yarn dlx jsr add @vbudovski/paseri
npx jsr add @vbudovski/paseri
This library wouldn't exist without Zod as a source of inspiration, with its incredibly expressive, and straightforward API. Zod is an excellent, and very mature library, and if the highest possible performance isn't a key requirement, then it is a great choice.
It sets an incredibly high bar for parsing performance, and is the current benchmark for this implementation. Some of the goals of this library differ from the goals of Valita, but it is nonetheless an excellent project.
The list may be expanded in 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 usage1.
- High performance2, 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.
Paseri uses the Deno runtime rather than Node, and requires Deno 2.1.4 or later. Packages are published to the JSR registry only, and publishing is performed automatically by CI.
paseri-lib
contains the sources for the library.paseri-docs
contains the documentation, built with Astro and Starlight.
After cloning the repository, be sure you set up the git hooks using the following command:
deno task init
deno test
deno bench
Footnotes
-
An excellent article on the concept of type-driven design. ↩
-
It's certainly possible to create much faster parsers using dynamic code execution or ahead-of-time compilation, but they each have drawbacks in the form of potential security issues or added complexity from requiring a manual compilation step. ↩