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

@xndrjs/domain-valibot

v0.2.0

Published

Valibot adapter for @xndrjs/domain with function-first APIs: valibotToValidator and valibotFromKit, plus full domain re-export.

Readme

@xndrjs/domain-valibot

Valibot 1.x adapter for @xndrjs/domain. Use valibotToValidator(schema) for a Validator<input, output>, and valibotFromKit(kit) to compose core kits as nested Valibot fields.

This package re-exports @xndrjs/domain (domain, compose + types), so you can import from one place when you use Valibot.

Install

pnpm add @xndrjs/domain-valibot valibot

Quickstart (step 3 in the stack)

Import from @xndrjs/domain-valibot to get both the adapter helpers and the domain re-export.

import * as v from "valibot";
import { domain, valibotToValidator } from "@xndrjs/domain-valibot";

const Email = domain.primitive("Email", valibotToValidator(v.pipe(v.string(), v.email())));
import * as v from "valibot";
import { domain, pipe, valibotToValidator } from "@xndrjs/domain-valibot";

const ItemSchema = v.object({
  id: v.string(),
  tier: v.picklist(["free", "pro"]),
  count: v.pipe(v.number(), v.integer(), v.minValue(0)),
});

const ProTier = domain
  .proof("ProTier", valibotToValidator(ItemSchema))
  .refineType((row): row is typeof row & { tier: "pro" } => row.tier === "pro");

const Stocked = domain
  .proof("Stocked", valibotToValidator(ItemSchema))
  .refineType((row): row is typeof row & { count: number } => row.count > 0);

const out = pipe({ id: "i-1", tier: "pro", count: 4 }, Stocked.assert, ProTier.assert);
import * as v from "valibot";
import { domain, valibotFromKit, valibotToValidator } from "@xndrjs/domain-valibot";

const Address = domain.shape(
  "Address",
  valibotToValidator(
    v.object({
      type: v.optional(v.literal("Address"), "Address"),
      city: v.string(),
    })
  )
);

const User = domain.shape(
  "User",
  valibotToValidator(
    v.object({
      type: v.optional(v.literal("User"), "User"),
      address: valibotFromKit(Address),
    })
  )
);

Recipes

Nested sub-shape composition from kit

  • Keep child kits in core modules and embed them with valibotFromKit(childKit).
  • Compose arrays/optionals with normal Valibot operators around valibotFromKit.

Capabilities + patch re-validation

import * as v from "valibot";
import { domain, valibotToValidator } from "@xndrjs/domain-valibot";

const UserShape = domain.shape(
  "User",
  valibotToValidator(
    v.object({
      type: v.optional(v.literal("User"), "User"),
      displayName: v.string(),
      isVerified: v.boolean(),
    })
  )
);

const User = domain
  .capabilities<{ displayName: string; isVerified: boolean }>()
  .methods((patch) => ({
    verify(user) {
      return patch(user, { isVerified: true });
    },
  }))
  .attach(UserShape);

Cross-engine composition pattern

  • Keep the semantic model in domain modules.
  • Adapt payload validators per boundary with valibotToValidator (or zodToValidator where needed).
  • Use valibotFromKit to compose existing domain kits in Valibot schemas without duplicating domain semantics.

Pitfalls and design decisions

  • Adapter schema ergonomics are not core modeling APIs; keep domain transitions in capabilities/proofs.
  • is checks depend on shape prototype markers; JSON transport strips prototype, so re-enter via create.
  • Use proofs and pipe for explicit guarantee chains instead of manual narrowing.

License

MIT