npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@othree.io/auditor

v5.0.0

Published

A functional validation library built on Zod that returns Optional<T> instead of throwing exceptions

Downloads

166

Readme

@othree.io/auditor

A functional validation library built on Zod. Validation results are returned as Optional<T> from @othree.io/optional, so invalid input never throws — you get either a filled Optional with the parsed value or an empty one carrying a ValidationError.

Install

npm install @othree.io/auditor

Peer dependencies:

npm install zod @othree.io/optional

Usage

zodValidate

Creates a curried validation function from any Zod schema. Returns Optional<T> — filled on success, empty with a ValidationError on failure.

import { z } from 'zod'
import { zodValidate } from '@othree.io/auditor'

const UserSchema = z.object({
    name: z.string().min(1),
    age: z.number().int().nonnegative(),
}).strict()

type User = z.infer<typeof UserSchema>

const validateUser = zodValidate({ constraints: UserSchema })

const result = validateUser({ name: 'Alice', age: 30 })

if (result.isPresent) {
    console.log(result.get()) // { name: 'Alice', age: 30 }
} else {
    console.log(result.getError().errors)
    // e.g. { name: ['String must contain at least 1 character(s)'] }
}

Built-in constraints

The library exports common string constraints ready to use with zodValidate:

| Constraint | Description | |------------------|------------------------------------------------------| | NonEmptyString | Trims whitespace, requires at least 1 character | | CountryISOCode | Two uppercase letters (e.g. US, MX) | | LanguageCode | Two lowercase letters (e.g. en, es) |

import { zodValidate, NonEmptyString, CountryISOCode, LanguageCode } from '@othree.io/auditor'

zodValidate({ constraints: NonEmptyString })(' hello ')      // Optional('hello')
zodValidate({ constraints: CountryISOCode })('US')           // Optional('US')
zodValidate({ constraints: LanguageCode })('es')             // Optional('es')
zodValidate({ constraints: LanguageCode })('BAD')            // Empty(ValidationError)

toValidationError

Converts a Zod ZodError into a ValidationError with per-field error messages. Used internally by zodValidate, but available if you need to work with Zod errors directly.

import { toValidationError } from '@othree.io/auditor'
import { z } from 'zod'

const result = z.string().min(1).safeParse('')

if (!result.success) {
    const error = toValidationError(result.error)
    console.log(error.errors) // { input: ['String must contain at least 1 character(s)'] }
}

ValidationError

When validation fails, the Optional carries a ValidationError with per-field error messages:

import { ValidationError } from '@othree.io/auditor'

const error = new ValidationError({
    email: ['Required'],
    age: ['Expected number, received string'],
})

error.name    // 'ValidationError'
error.errors  // { email: ['Required'], age: ['Expected number, received string'] }

Scripts

npm test      # run tests with 100% coverage threshold
npm run build # compile TypeScript to lib/

License

ISC