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

@felipe.boff/vale

v1.1.0

Published

TypeScript-first runtime validator with coercion, composable schemas, and path-based error reporting

Readme

Vale

TypeScript-first runtime validator with coercion, composable schemas, and path-based error reporting.

Validate and resolve unknown input (for example APIs, forms, or config) into typed values. Vale returns a result object instead of throwing so validation failures can be handled explicitly. When needed you can use valeValidate to throw on failure.

Features

  • Coercion
    Primitives like number, integer, boolean, and date accept string input and coerce when valid.
    "42" becomes 42, "true" becomes true.

  • Composable schemas
    Build object, array, and nested structures. Combine with .optional(), .nullable(), .default(), .into(), and .guard().

  • Path-based errors
    Each issue includes a path such as ["author", "age"]. This makes it easy to show field errors in UI or logs.

  • Type inference
    Use InferVale<typeof schema> to derive the TypeScript type from a schema.

  • No dependencies
    Pure TypeScript / JavaScript with zero runtime dependencies.


Installation

npm

npm i @felipe.boff/vale

yarn

yarn add @felipe.boff/vale

pnpm

pnpm add @felipe.boff/vale

Quick start

import { vale, type InferVale } from "@felipe.boff/vale";

const userSchema = vale.object({
  name: vale.string(),
  age: vale.integer(),
  email: vale.email(),
  active: vale.boolean().default(true),
});

type User = InferVale<typeof userSchema>;

const user = userSchema.resolve({
  name: "Jane",
  age: 28,
  email: "[email protected]",
});

console.log(user);

// If you want the non-throwing result object:
const result = userSchema.probe({
  name: "Jane",
  age: 28,
  email: "invalid-email",
});
if (!result.ok) console.log(result.issues);

Schema types

Method Description

vale.string()	String
vale.number()	Number (coerces from string)
vale.integer()	Integer (coerces from string)
vale.boolean()	Boolean (coerces "true" / "false")
vale.date()	Date (coerces from string or number)
vale.email()	String matching email format
vale.uuid()	UUID v4 string
vale.objectId()	MongoDB-style ObjectId string
vale.enum([...])	One of the given string literals
vale.object({...})	Object with specified shape
vale.array(schema)	Array of validated items

Modifiers

Schemas can be extended with modifiers.

.optional()
undefined is accepted. Output type becomes T | undefined.

.nullable()
null is accepted. Output type becomes T | null.

.nullish()
null or undefined accepted. Also treats `""` and `"null"` (query-string values) as nullish and returns `undefined`.

.default(value)
Use value when input is `undefined`, `null`, `""`, or `"null"`.

.into(fn)
Transform parsed value.

vale.string().into((v) => v.trim())

.guard(predicate, message)
Custom validation refinement.

vale.number().guard((n) => n > 0, "Must be positive")

.lock()
Rejects unrecognized object keys (best-effort key-set comparison).

Nested schemas

Schemas can be composed.

const addressSchema = vale.object({
  city: vale.string(),
  zip: vale.string(),
});

const userSchema = vale.object({
  name: vale.string(),
  address: addressSchema,
});

Result type

schema.probe(input) returns a discriminated union.

type ValeResult<T> =
  | { ok: true; value: T }
  | { ok: false; issues: ValeIssue[] }

type ValeIssue = {
  path: (string | number)[]
  code: string
  message: string
}

Example issue

{
  path: ["age"],
  code: "integer",
  message: "Expected integer"
}

Throw on failure

Use schema.resolve() (or valeValidate) to throw a ValeError.

import { valeValidate, ValeError } from "@felipe.boff/vale";

try {
  const user = valeValidate(userSchema, rawInput);
  console.log(user);
} catch (err) {
  if (err instanceof ValeError) {
    console.log(err.issues);
  }
}

License

ISC Felipe Boff