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

@bota-apps/schema-utils

v0.9.2

Published

The Zod runtime behind @bota-apps/types: currency/money, dynamic form/field/detail validators, domain-definition form builders, plus optional i18n (./i18n) helpers. Every schema is proven to align with its @bota-apps/types contract. (Env/runtime config va

Readme

@bota-apps/schema-utils

The Zod runtime behind @bota-apps/types: currency/money schemas and formatters, dynamic form/field/detail validators, and domain-definition form builders — plus optional localization helpers on subpaths. Every schema is proven to align with its @bota-apps/types contract at build time (via satisfies z.ZodType<T> + Equal<> assertions), so the runtime and the types can never silently drift.

Environment/runtime config validators are not here — they live in @bota-apps/app-config.

Install

pnpm add @bota-apps/schema-utils
# zod is bundled as a dependency; @bota-apps/types comes along transitively

Usage

import {
  money,
  moneySchema,
  sumMoney,
  currencies,
  currencyCodes,
  formatMoney,
  createCurrencyFormatter,
  dynamicFieldSchema,
  optionsFromEnum,
  registrationSchemaSchema,
  buildCreateFormSchema,
  buildDetailSchema,
  badgeTones,
} from "@bota-apps/schema-utils";

Currency & money

Money is { amount, currency }; the formatters cache their Intl.NumberFormat instances internally (locale-data resolution is expensive and they run per table cell / chart tick):

const price = money(1145000, "USD"); // { amount: 1145000, currency: "USD" }

formatMoney(price); // "$1,145,000.00"
formatMoneyCompact(price); // compact form (e.g. "$1.1M")
formatMoneyShort(price); // short form

sumMoney([money(10, "USD"), money(5, "USD")], "USD"); // { amount: 15, currency: "USD" }

moneySchema.parse({ amount: 100, currency: "USD" }); // validated Money

Format a bare amount against a currency code, or build a reusable formatter over your own currency registry:

formatCurrency(1145000, "USD"); // "$1,145,000.00"
getCurrencyLabel("USD"); // human label from `currencies`

const fmt = createCurrencyFormatter(); // defaults to the built-in registry
fmt.format(1145000, "USD");

Dynamic form / field schemas

Validate schema-driven forms and derive <select> options from a Zod enum:

import { z } from "zod";

const roleEnum = z.enum(["admin", "member", "viewer"]);
optionsFromEnum(roleEnum); // [{ value: "admin", label: "Admin" }, …]
optionsFromEnum(roleEnum, { admin: "Administrator" }); // override individual labels

registrationSchemaSchema.parse(remoteSchema); // validate a form definition
dynamicFieldSchema.parse(remoteField); // validate a single field

Domain-definition builders

Turn an app's DomainDefinition into typed registration and detail schemas:

const createSchema = buildCreateFormSchema(projectDefinition);
const detailSchema = buildDetailSchema(projectDefinition);

Localization (subpath)

Localization helpers stay off the core entry so the base import carries no i18n concern. There is no i18n library dependency — you pass your own t:

import {
  translatedOptionsFromEnum,
  localizeFormSchema,
  localizeDetailSchema,
} from "@bota-apps/schema-utils/i18n";

translatedOptionsFromEnum(roleEnum, t, "roles"); // localized <select> options
const localized = localizeFormSchema(schema, { t, enumT }); // translated labels/placeholders

Subpaths

| Import | What | | ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | @bota-apps/schema-utils | Currency/money (money, moneySchema, sumMoney, currencies, currencyCodes, currencyCodeSchema, createCurrencyFormatter, formatMoney*, formatCurrency*, getCurrencyLabel), dynamic-form zod (dynamicFieldSchema, dynamicFieldTypeEnum, optionsFromEnum, registrationSchemaSchema, formSectionSchema), domain builders (buildCreateFormSchema, buildDetailSchema), badgeTones — plus re-exported types from @bota-apps/types | | @bota-apps/schema-utils/localize | localizeFormSchema, localizeDetailSchema, translatedOptions, translatedOptionsFromEnum, collectSchemaKeys, LocalizeContext | | @bota-apps/schema-utils/i18n | Re-exports the localize surface (stable alias for the localization helpers) |

Part of the @bota-apps packages monorepo.