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

silentium-validation

v0.0.7

Published

Validation library based on silentium

Readme

A reactive validation library built on the Silentium library for TypeScript applications. Provides asynchronous and reactive validation capabilities with a simple, composable API.

Features

  • Reactive validation with asynchronous support
  • Composable validation rules
  • TypeScript-first design
  • Built-in common validation rules
  • Integration with Silentium reactive primitives

Installation

npm install silentium-validation

Basic Usage

Validation Rules

Create validation items with rules:

import { Required, Integer } from 'silentium-validation';

const form = {
  email: '',
  password: '',
};
const rules = {
  email: [Required, (v) => /\S+@\S+\.\S+/.test(v) || 'Invalid email'],
  password: [Required]
}

const $validationItems = Computed(ValidationItems, form, rules);

Custom Rules

Define custom validation rules:

const MinLength = (min: number) => (value: string) =>
  value.length >= min || `Must be at least ${min} characters`;

const form = {
  username: '',
  age: 0,
  password: '',
};
const rules = {
  password: [MinLength(8)]
}

const $validationItems = Computed(ValidationItems, form, rules);

Running Validation

Use ValidationErrors to get validation results:

import { ValidationErrors } from 'silentium-validation';

const $errors = ValidationErrors($validationItems);
const errors = await $errors;

// Result: { username: [], age: [], password: ['Must be at least 8 characters'] }

Checking Validation Status

Use Validated to check if form is valid:

import { Validated, Computed, LateShared } from 'silentium';
import { Validated } from 'silentium-validation';

const $errors = LateShared(errors);
const $isValid = Computed(Validated, $errors);

const isValid = await $isValid; // false if any errors exist

API Reference

Types

type ValidationErrorType = Record<string, string[]>;

interface ValidationItem {
  value: unknown;
  key: string;
  rules: ConstructorType<any, ValidationRule>[];
}

type ValidationRule = MaybeMessage<string | boolean>;

Functions

ValidationErrors(items: ValidationItem[])

Returns a MessageType<ValidationErrorType> containing all validation errors.

Validated(errors: ValidationErrorType)

Returns true if no validation errors exist, false otherwise.

Built-in Rules

Required

Validates that a value is truthy.

Required(value) // Returns true or "Field required"

Integer

Validates that a value is an integer.

Integer(value) // Returns true or "Must be integer"

Advanced Usage

Reactive Validation

Combine with Silentium's reactive primitives for real-time validation:

import { Computed, LateShared } from 'silentium';
import { ValidationErrors, Validated } from 'silentium-validation';

const $form = LateShared({
  email: '',
  password: '',
});

const $validationItems = Computed(ValidationItems, $form, {
    email: [Required, (v) => /\S+@\S+\.\S+/.test(v) || 'Invalid email'],
    password: [Required, MinLength(8)]
});

const $errors = ValidationErrors($validationItems);
const $isValid = Computed(Validated, $errors);

// Reactively update validation as form data changes
$form.use({ email: '[email protected]', password: 'newpassword' });

License

MIT