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

@umpire/json

v1.0.0

Published

JSON schema parsing and portable named checks for @umpire/core

Downloads

207

Readme

@umpire/json

Portable schema parsing and serialization for @umpire/core, plus portable namedValidators.*() helpers that round-trip cleanly through JSON.

@umpire/dsl now owns the pure expression layer (Expr, expr.*, compileExpr(), getExprFieldRefs()). @umpire/json owns the JSON-aware additions: expr.check(), namedValidators.*(), and portable JSON rule builders.

Docs · Quick Start

Install

npm install @umpire/core @umpire/dsl @umpire/json

Usage

import { check, enabledWhen, umpire } from '@umpire/core'
import { namedValidators, fromJson, toJson } from '@umpire/json'

const schema = {
  version: 1,
  fields: {
    email: { isEmpty: 'string' },
    submit: {},
  },
  rules: [],
  validators: {
    email: { op: 'email', error: 'Enter a valid email address' },
  },
}

const { fields, rules, validators } = fromJson(schema)

const mergedRules = [
  ...rules,
  enabledWhen('submit', check('email', namedValidators.email()), {
    reason: 'Enter a valid email address',
  }),
]

const ump = umpire({
  fields,
  rules: mergedRules,
  validators,
})

const json = toJson({
  fields,
  rules: mergedRules,
  validators,
})

API

fromJson(schema)

Parses a portable Umpire JSON schema into { fields, rules, validators } values you can pass into umpire() or compose with hand-written rules.

toJson({ fields, rules, validators, conditions })

Serializes a TypeScript config back into the portable JSON contract.

  • Rules hydrated from JSON round-trip exactly
  • Validators hydrated from JSON round-trip exactly
  • Hand-written rules serialize when they map cleanly to the contract
  • Hand-written validators serialize when they use portable validator metadata
  • Unsupported pieces go into excluded instead of disappearing

namedValidators.*()

Named validators for use with check(field, validator) and JSON validators:

  • namedValidators.email()
  • namedValidators.url()
  • namedValidators.matches(pattern)
  • namedValidators.minLength(n)
  • namedValidators.maxLength(n)
  • namedValidators.min(n)
  • namedValidators.max(n)
  • namedValidators.range(min, max)
  • namedValidators.integer()

Use these when you want a validator or check-backed rule to survive the JSON boundary. Plain functions, regexes, and library schemas still work at runtime, but they stay TypeScript-specific.

expr.check() and JSON-aware builders

expr.check() is JSON-specific and remains in @umpire/json.

Use it with JSON-aware builders such as enabledWhenExpr, requiresExpr, disablesExpr, and fairWhenExpr when a rule must round-trip through JSON.

For non-check expression authoring and compilation, import from @umpire/dsl.

validators

Use top-level validators for field-local correctness checks that should surface valid / error through ump.check():

{
  "validators": {
    "email": { "op": "email", "error": "Enter a valid email address" }
  }
}

This is the first-class validation path in @umpire/json.

Top-level "check" rules still exist for legacy compatibility, but they remain structural fairness rules rather than validator metadata.

excluded

excluded is the escape hatch for rules or field semantics that cannot be serialized safely. It is informational only. Its job is to tell the next runtime, "there was more logic here, and you'll need to recreate it natively."

When present, excluded.key gives an exclusion a stable identity so later serializations can replace or remove it once that slot becomes portable.

Docs