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

borboleta

v0.0.4

Published

Convert [JSON Schema](https://json-schema.org/) definitions into [Angular Signal Forms](https://angular.dev/guide/forms/signals/overview) schema functions.

Readme

Borboleta 🦋

Convert JSON Schema definitions into Angular Signal Forms schema functions.

Requires Angular 21+ — Signal Forms are experimental. See the Angular docs for details.

Why "Borboleta"?

Borboleta is Portuguese for butterfly — a symbol of transformation. This library transforms JSON Schema definitions into Angular Signal Forms schemas, much like a caterpillar becomes a butterfly. 🦋

Installation

npm install borboleta

Peer dependencies: @angular/core, @angular/common, @angular/forms (all ^21.2.0).

Quick start

import { signal } from '@angular/core';
import { form } from '@angular/forms/signals';
import { toSignalSchema } from 'borboleta';

const jsonSchema = {
  type: 'object',
  required: ['email', 'age'],
  properties: {
    email: { type: 'string', format: 'email' },
    age:   { type: 'number', minimum: 18, maximum: 120 },
    role:  { type: 'string', enum: ['admin', 'user', 'guest'] },
  },
};

const model = signal({ email: '', age: 0, role: '' });
const myForm = form(model, toSignalSchema(jsonSchema));

This generates the same validators as writing the schema by hand:

const myForm = form(model, (s) => {
  required(s.email);
  email(s.email);
  required(s.age);
  min(s.age, 18);
  max(s.age, 120);
  validate(s.role, ({ value }) => {
    const v = value();
    if (v != null && v !== '' && !['admin', 'user', 'guest'].includes(v)) {
      return { kind: 'enum', message: 'Must be one of: admin, user, guest' };
    }
    return null;
  });
});

Supported JSON Schema keywords

| JSON Schema | Signal Forms validator | | ----------------------- | ----------------------------- | | required | required() | | enum | validate() (custom) | | minimum / maximum | min() / max() | | minLength / maxLength | minLength() / maxLength() | | pattern | pattern() | | format: "email" | email() | | Nested object | Recursive descent | | items (array) | applyEach() |

Adding custom validators

Use composeSchemas() to layer custom validators on top of the generated ones:

import { form, validate, required } from '@angular/forms/signals';
import { toSignalSchema, composeSchemas } from 'borboleta';

const myForm = form(
  model,
  composeSchemas(
    toSignalSchema(jsonSchema),
    (s) => {
      // Custom: URL must use HTTPS
      validate(s.run.url, ({ value }) => {
        if (!value().startsWith('https://')) {
          return { kind: 'https', message: 'URL must use HTTPS' };
        }
        return null;
      });

      // Custom: conditional required
      required(s.monitor.url, {
        when: ({ valueOf }) => valueOf(s.monitor.isMonitored),
      });
    },
  ),
);

Or just call toSignalSchema() inside your own schema function — no utility needed:

const myForm = form(model, (s) => {
  toSignalSchema(jsonSchema)(s);
  validate(s.run.url, /* ... */);
});

API

toSignalSchema<T>(jsonSchema: JsonSchema): SchemaFn<T>

Converts a JSON Schema object into an Angular Signal Forms SchemaFn<T>. Pass the result directly to form() or combine it with composeSchemas().

composeSchemas<T>(...schemas: SchemaFn<T>[]): SchemaFn<T>

Combines multiple schema functions into one. Each schema is called in order on the same SchemaPathTree, so validators accumulate.

JsonSchema (type)

TypeScript interface describing the subset of JSON Schema Draft-07 that Borboleta understands.

Development

npm install          # Install dependencies
npm run build        # Build the library (output: dist/borboleta/)
npm test             # Run tests (Vitest)

License

MIT