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

valix-validator

v1.0.1

Published

Valix-validator helps you validate data in JavaScript and TypeScript with easy-to-use, reusable schemas.

Readme

Valix-validator

Valix-validator is a lightweight, type-safe package that helps you validate data in JavaScript and TypeScript with easy-to-use, reusable schemas.

Installation

npm i valix-validator

Features

  • 💪 Fully TypeScript compatible with type inference
  • 🔄 Framework-agnostic (works with any JS framework)
  • 🔍 Rich validation rules for common types
  • 🧩 Composable schemas for complex validation
  • 🛡️ Runtime type checking
  • 📊 Detailed error messages

Basic Usage

import v from 'valix-validator';

// Define a schema
const userSchema = v.object({
  username: v.string().minLength(3).maxLength(20),
  email: v.string().email(),
  age: v.number().min(18).integer(),
  isActive: v.boolean()
});

// Type is inferred from schema
type User = v.infer<typeof userSchema>;

// Validate data
try {
  const validatedUser = userSchema.parse({
    username: 'john_doe',
    email: '[email protected]',
    age: 25,
    isActive: true
  });
  
  // validatedUser is typed as User
  console.log(validatedUser);
} catch (error) {
  console.error('Validation error:', error);
}

// Safe parsing (doesn't throw)
const result = userSchema.safeParse({
  username: 'jo', // too short
  email: 'not-an-email',
  age: 17.5,
  isActive: true
});

if (!result.success) {
  console.log('Invalid data:', result.error);
} else {
  console.log('Valid data:', result.value);
}

Available Validators

  • v.string() - Validates strings
  • v.number() - Validates numbers
  • v.boolean() - Validates booleans
  • v.date() - Validates Date objects
  • v.array() - Validates arrays
  • v.object() - Validates objects
  • v.union() - Validates union types
  • v.literal() - Validates literal values
  • v.tuple() - Validates tuples
  • v.record() - Validates records (objects with specific key/value types)
  • v.any() - Accepts any value

Common Validator Methods

String Methods

  • .minLength(n) - String must be at least n characters
  • .maxLength(n) - String must not exceed n characters
  • .pattern(regex) - String must match the regex pattern
  • .email() - String must be a valid email
  • .url() - String must be a valid URL
  • .uuid() - String must be a valid UUID

Number Methods

  • .min(n) - Number must be at least n
  • .max(n) - Number must not exceed n
  • .integer() - Number must be an integer
  • .positive() - Number must be positive
  • .negative() - Number must be negative

Date Methods

  • .min(date) - Date must be after the specified date
  • .max(date) - Date must be before the specified date

Array Methods

  • .minLength(n) - Array must have at least n items
  • .maxLength(n) - Array must not exceed n items

Object Methods

  • .strict() - Object must not have extra properties

Common Methods for All Types

  • .optional() - Makes the value optional (value | undefined)
  • .nullable() - Makes the value nullable (value | null)

License

MIT