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

@bemedev/valibot-extended

v0.1.3

Published

Valibot utilities

Readme

@bemedev/valibot-extended

Extra helpers for Valibot: byFunction, deepPartial, soa and trueO.

Installation

pnpm add @bemedev/valibot-extended
# or
npm install @bemedev/valibot-extended

valibot (^1.5.0) ships as a direct dependency, so it does not need to be installed separately. The package is published as a dual ESM/CJS build with its type declarations, so it works in both import and require contexts.

Exports

| Export | Sub-path | Description | | ------------------- | -------------- | ------------------------------------------------------------------------ | | byFunction | /byFunction | Lazy schema evaluator returning the schema built by a factory | | deepPartial | /deepPartial | Recursively converts an object, tuple or array schema into a partial one | | soa | /soa | Union accepting either a single value or an array of values | | trueO | /trueO | Schema accepting only plain objects | | DeepPartial | /deepPartial | Recursive deep partial type | | DeepPartialSchema | /deepPartial | Schema type produced by deepPartial |

Every export is available from the package root and from a dedicated sub-path:

import { byFunction, deepPartial, soa, trueO } from '@bemedev/valibot-extended';
import { deepPartial } from '@bemedev/valibot-extended/deepPartial';

byFunction

Defers the creation of a schema, which keeps recursive and mutually referencing schemas easy to declare.

import { byFunction } from '@bemedev/valibot-extended';
import * as v from 'valibot';

const schema = byFunction(() => v.object({ name: v.string(), age: v.number() }));

type User = v.InferOutput<typeof schema>;
// { name: string; age: number }

const parse = v.parser(schema);
parse({ name: 'Gartner', age: 40 }); // => { name: 'Gartner', age: 40 }
parse({ name: 'Gartner', age: 'old' } as any); // => throws

deepPartial

Turns every object entry optional, recursively. Arrays and tuples recurse into their items while keeping their shape, and any other schema is returned untouched. Objects are rebuilt as strict partial objects, so unknown keys are rejected.

import { deepPartial } from '@bemedev/valibot-extended/deepPartial';
import * as v from 'valibot';

const base = v.object({
  name: v.string(),
  nested: v.object({ tag: v.string() }),
  tags: v.array(v.string()),
});

const schema = deepPartial(base);
const parse = v.parser(schema);

parse({}); // => {}
parse({ name: 'Gartner', nested: { tag: 'old' } }); // => valid
parse({ tags: ['smart', 'strong'] }); // => valid
parse({ toto: 67 } as any); // => throws (unknown key)

type Shape = v.InferOutput<typeof schema>;
// { name?: string; nested?: { tag?: string }; tags?: string[] }

Tuples keep their length and element order:

const tuple = deepPartial(v.tuple([base, v.string()]));
// [{ name?: string; ... }, string]

DeepPartial and DeepPartialSchema

Both types let you describe a deeply optional shape without re-declaring it, and pin a schema variable to the exact schema deepPartial produces.

import {
  deepPartial,
  type DeepPartial,
  type DeepPartialSchema,
} from '@bemedev/valibot-extended';
import * as v from 'valibot';

const base = v.object({ name: v.string(), nested: v.object({ tag: v.string() }) });

type Shape = DeepPartial<v.InferOutput<typeof base>>;
// { name?: string; nested?: { tag?: string } }

const schema: DeepPartialSchema<typeof base> = deepPartial(base);

soa

Wraps a schema into a union accepting either a single value or an array of values — handy for struct-of-arrays payloads coming from a CSV or an API.

import { soa } from '@bemedev/valibot-extended';
import * as v from 'valibot';

const schema = soa(v.object({ name: v.string(), age: v.number() }));
const parse = v.parser(schema);

const many = [
  { name: 'Gartner', age: 40 },
  { name: 'Bri', age: 20 },
];

parse({ name: 'Gartner', age: 40 }); // => { name: 'Gartner', age: 40 }
parse([]); // => []
parse(many); // => array of objects
parse(123 as any); // => throws

trueO

Validates that the input is a "true" plain object. Arrays, null, primitives, class instances and any object with a custom prototype are rejected, while objects created from {} or Object.create(null) are accepted.

import { trueO } from '@bemedev/valibot-extended/trueO';
import * as v from 'valibot';

const parse = v.parser(trueO);

parse({}); // => {}
parse({ name: 'Gartner' }); // => { name: 'Gartner' }
parse({ nested: { tag: 'old' }, tags: ['smart'] }); // => valid
parse(Object.assign(Object.create(null), { name: 'Gartner' })); // => valid
parse([]); // => throws
parse(new Date()); // => throws
parse(Object.create({ toto: 67 })); // => throws
parse(123 as any); // => throws

type Shape = v.InferOutput<typeof trueO>;
// Record<string, any>

Development

From packages/valibot:

pnpm run build   # bundle the library with rolldown
pnpm run test    # run the Vitest suite, coverage enabled by default
pnpm run lint    # format with oxfmt, then lint with oxlint

Licence

MIT

CHANGE_LOG

Read CHANGELOG.md for more details about the changes.

Author

chlbri ([email protected])

My github

Links