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

@oniryk/forma

v0.1.1

Published

Schema-driven invalid payload generator for validation testing

Readme

@oniryk/forma

Schema-driven invalid payload generator for validation testing. Produces payload variations that violate JSON Schema constraints — null, omission, wrong types, bounds, formats, and patterns — so you can verify your validation logic handles them correctly.

Installation

npm install @oniryk/forma

Usage

Generate payloads that violate schema constraints:

import { Forma } from '@oniryk/forma';
import { z } from 'zod';

const userSchema = z.object({
  email: z.string().email(),
  age: z.number().min(18).max(120),
  bio: z.string().nullable(),
});

// Convert Zod to JSON Schema for Forma
const schema = userSchema.toJSONSchema();
const forma = new Forma(schema);

// Iterate over all edge cases
for (const payload of forma.variate()) {
  const response = await fetch('http://localhost:3000/api/users', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify(payload),
  });

  // Verify proper error handling
  if (!response.ok) {
    console.log(`✓ Correctly rejected invalid payload (status: ${response.status})`);
  } else {
    console.warn('✗ Should have been rejected but was accepted');
  }
}

This package works with any JSON Schema. Zod is used in the example but not required.

Rate limit awareness: variate() can yield many payloads — schemas with nested objects and arrays can produce hundreds of variations. When testing against external APIs, consider adding a throttle or limit to avoid overwhelming the server.

Features

  • JSON Schema Support — Works with standard JSON Schema from any validator or framework (Zod, Vine, ArkType, etc.)
  • Comprehensive Coverage — Generates variations for:
    • Null values injected into non-nullable fields
    • Required fields omitted from the payload
    • Constraint violations (min/max, length, pattern, enum, format, multipleOf)
    • Incorrect types (string instead of number, object instead of array, etc.)
    • Nested objects and array items (applies all violations recursively)

API Reference

Forma(schema)

Creates a new payload variation generator.

Parameters:

  • schema — JSON Schema object describing the expected structure. Must describe an object (type: "object" or properties defined).

Returns: New Forma instance

.variate(): Generator<Variation>

Lazily yields payload variations, one per iteration. Each variation is a shallow clone of the valid payload with exactly one field mutated.

Yields: Objects with a single field altered to test a specific violation:

  • Null for non-nullable fields
  • Omission of required fields
  • Wrong type value (e.g., string where a number is expected)
  • Constraint violation (below minimum, above maximum, invalid format, etc.)
  • Nested violations inside objects and array items (recursive)

AI-Assisted Development

This package was developed with the assistance of artificial intelligence as a productivity tool, under human supervision and direction.

License

MIT