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

variable-value-validator

v1.0.1

Published

Minimal schema validation for TypeScript and JavaScript.

Readme

What is it ?

variable-value-validator is a minimal (standard-schema compliant) schema validation library enabling type-safe code with unsafe data such as serialized data, API responses, and more.

Example

// defining a schema describing the user object :
const userSchema = vvv.object({
	id: vvv.number(),
	name: vvv.string(),
	isActive: vvv.boolean({ optional: true }),
	tags: vvv.array(vvv.string()),
})

// if a TypeScript type is needed it can be inferred from the schema :
type User = SchemaToType<typeof userSchema>

// example unsafe data :
const response = await fetch("api.com/user/1")
const user = await response.json()

if (userSchema.guard(user)) {
	// `user` is now guaranteed to be of type User
}

Installation

# npm
npm install variable-value-validator
# yarn
yarn add variable-value-validator
# pnpm
pnpm add variable-value-validator

Schema creation methods

  • Primitives: vvv.string(), vvv.number(), vvv.boolean(), vvv.undefined(), vvv.null(), vvv.nullish() (null or undefined), vvv.function() and vvv.unknown() (always valid).
  • Objects: vvv.object(shape: Record<string, Schema>), vvv.array(items: Schema[]), record(values: Schema[]), set(values: Schema[]), map(keys: Schema[], values: Schema[]), vvv.instance(constructor: new (...args: any[]) => Object) (class instances).
  • Other: vvv.union(members: Schema[]) ("OR" schema association).

All of the schema creation methods accept an optional options object which can have the following optional properties:

  • optional: Marks the property as optional when used with vvv.object (e.g. vvv.object({ foo: string({ optional: true }) })).
  • predicates: A function or an array of functions to add custom validation (e.g. vvv.number({ predicates: (num) => Number.isInteger(num) })).

Schemas

Every schema has the following methods :

  • guard(value: unknown): A type guard for that schema. If the value is valid in respect to that schema it will return true, else it will return false.
  • errors(value: unknown): An array of issues, a valid value returns an empty array.