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

desy

v0.0.14

Published

- [Install](#install) - [Basic usage](#basic-usage) - [Key ideas](#key-ideas) - [Key features](#key-features) - [Examples](#examples) - [API](#api) - [Benchmark](#benchmark)

Readme

desy - Dead Extraordinary Simple Yup

Install

npm install desy

Basic usage

Creating a simple string schema

import {d} from 'desy';

// creating a schema for strings
const mySchema = d.string();

// validating
mySchema.validate('tuna'); // => ""
mySchema.validate(12); // => "Value must be string"

Key ideas

  • be simple
  • be as fast as point 1 allows

Key features

  • Stop validating on the first error. Desy stops validating on the first error and returns it.
  • A string is an indicator. Desy returns an empty string in a valid case. In case of an error, Desy returns a string with a description of the error.
  • No throwing errors. Desy only returns an empty or non-empty string.

Examples

Deep schema

const schema = d.array(
  d.object({
    type: d.string().oneOf(['person']),
    hair: d.string().oneOf(['blue', 'brown']),
    active: d.boolean(),
    name: d.string(),
    age: d.number().int(),
    hobbies: d.array(d.string()),
    address: d.object({
      street: d.string(),
      zip: d.string(),
      country: d.string(),
    }),
  }),
);
schema.validate(people);

Get schema's types

import {d, InferDesy} from 'desy';

const userSchema = d.object({
  username: d.string(),
});

const error = userSchema.validate({username: 'Ludwig'}); // error is ""

// extract the inferred type
type User = InferDesy<typeof user>; // { username: string }

API

Common

  • validate(value: any)
const schema = d.mixed();

schema.validate('a'); // valid
schema.validate(''); // valid
schema.validate(null); // valid
  • .test(func: (value: sting) => string)
const schema = d.mixed().test((value) => {
  if (value === 'world') {
    return ''; // valid case
  }

  return 'MUST BE WORLD'; // error message
});

schema.validate('hello'); // error
schema.validate('world'); // valid

mixed

  • mixed()
const schema = d.mixed();

schema.validate('a'); // valid
schema.validate(''); // valid
schema.validate(null); // valid

string

  • .string()
const schema = d.string();

schema.validate('a'); // valid
schema.validate(''); // error
schema.validate(null); // error
  • .length(chars)
const schema = d.string().length(1);

schema.validate('aa'); // error
schema.validate('a'); // valid
  • .optional()
const schema = d.string().optional();

schema.validate(''); // valid
schema.validate('a'); // valid
  • .oneOf(variants: string[])
const schema = d.string().oneOf(['hello', 'world']);

schema.validate('hello'); // valid
schema.validate('world'); // valid
schema.validate('foo'); // error
  • .regexp(regexp: Regexp)
const schema = d.string().regexp(/hello/i);

schema.validate('123hello'); // valid
schema.validate('hell'); // error
  • .min(min_chars: number)
const schema = d.string().min(1);

schema.validate(''); // error
schema.validate('a'); // valid
  • .max(max_chars: number)
const schema = d.string().max(1);

schema.validate('aa'); // error
schema.validate('a'); // valid

number

  • .number()
const schema = d.number();

schema.validate(42); // valid
schema.validate('42'); // error
  • .int()
const schema = d.number().int();

schema.validate(42); // valid
schema.validate(42.2); // error
  • .float()
const schema = d.number().float();

schema.validate(42); // error
schema.validate(42.2); // valid
  • .min(num: number)
const schema = d.number().min(1);

schema.validate(0); // error
schema.validate(1); // valid
  • .max(num: number)
const schema = d.number().max(1);

schema.validate(1); // valid
schema.validate(2); // error

boolean

  • .boolean()
const schema = d.boolean();

schema.validate(true); // valid
schema.validate(false); // valid
schema.validate(1); // error
  • .true()
const schema = d.boolean().true();

schema.validate(true); // valid
schema.validate(false); // error
  • .false()
const schema = d.boolean().false();

schema.validate(true); // error
schema.validate(false); // valid

date

  • .date()
const schema = d.date();

schema.validate(0); // valid
schema.validate('2024-03-15T23:21:48.605Z'); // valid
schema.validate(new Date()); // valid
schema.validate(undefined); // error
  • .min(date: DateValue)
const now = Date.now();
const schema = d.date().min(now);

schema.validate(now); // valid
schema.validate(now - 1); // error
  • .max(date: DateValue)
const now = Date.now();
const schema = d.date().max(now);

schema.validate(now); // valid
schema.validate(now + 1); // error

null

  • .null()
const schema = d.null();

schema.validate(null); // valid
schema.validate(undefined); // error

object

  • .object(objschema: Record<string, Schema>)
const schema = d.object({
  name: d.sting(),
});

schema.validate({name: 'alex'}); // valid
schema.validate({name: 'alex', age: 42}); // error
schema.validate({name: 42}); // error
  • .notStrict()
const schema = d
  .object({
    name: d.sting(),
  })
  .notStrict();

schema.validate({name: 'alex'}); // valid
schema.validate({name: 'alex', age: 42}); // valid
schema.validate({name: 42}); // error
  • .optionalFields(fileds: string[])
const schema = d
  .object({
    name: d.sting(),
  })
  .optionalFields(['name']);

schema.validate({name: 'alex'}); // valid
schema.validate({}); // valid
schema.validate({name: 42}); // error

array

  • .array(schemas: Schema[])
const schema = d.arrar(d.sting());

schema.validate(['hello', 'world']); // valid
schema.validate(['hello', 42]); // error
  • .length(length: number)
const schema = d.arrar(d.sting()).length(2);

schema.validate(['hello', 'world']); // valid
schema.validate(['world']); // error
  • .min(min_length: number)
const schema = d.arrar(d.sting()).min(2);

schema.validate(['hello', 'world']); // valid
schema.validate(['world']); // error
  • .max(max_length: number)
const schema = d.arrar(d.sting()).max(2);

schema.validate(['hello', 'world']); // valid
schema.validate(['hello', 'world', 'foo']); // error

benchmark

| | Simple string result | Complex object result | | ---- | ------------------------------------------------- | --------------------------------------------------- | | desy | x | x | | zod | 10x | 8x | | yup | 43x | 31x |

smaller is better