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

@elpandev/validator

v1.0.9

Published

validator

Readme

@elpandev/validator

A powerful TypeScript validation library for complex payloads with nested objects, arrays, and multiple validation rules. Perfect for API request validation, form data validation, and complex data structure validation.

Features

  • Nested Object Validation: Validate deeply nested objects with ease
  • Array Validation: Support for validating arrays and array elements
  • Multiple Rules: Apply multiple validation rules to single fields
  • Custom Messages: Customizable error messages for each rule
  • TypeScript First: Full TypeScript support with detailed type definitions
  • Flexible Rules: Support for simple values, objects, and arrays in the same schema
  • Bail Strategy: Optional early exit on first validation failure

Key Benefits

  • Enterprise Ready: Built for complex validation scenarios with type safety
  • Developer Friendly: Intuitive API with excellent TypeScript support
  • Highly Extensible: Easy to add custom validation rules
  • Performance Optimized: Efficient validation with minimal overhead
  • Comprehensive: Handles all common validation scenarios and edge cases

Installation

npm i @elpandev/validator

Quick Start

import { validate_payload, required, email, min } from '@elpandev/validator'

const payload = {
  name: 'John',
  email: '[email protected]',
  age: 25
}

const rules = {
  name: { required },
  email: { required, email },
  age: { required, min: min(18) }
}

const errors = validate_payload({ payload, rules })

// errors will be an empty object if validation passes
// or contain error messages for failed validations

Usage

import { array, integer, IPMessages, IPRules, max, min, required, some, validate_payload } from '@elpandev/validator'

const payload = {
  id: 987,
  status: 'active',
  info: {
    level: 3,
    tags: ['new', 'urgent']
  },
  preferences: null,
  meta: ['1', 1],
  labels: []
}

const rules = {
  id: { required, integer, min: min(1), max: max(100) },
  status: { required, some: some(['active', 'inactive']) },
  info: {
    level: { required: integer, max: max(10) },
    tags: [
      { required, array, min: min(2) },
      { required, some: some(['new', 'old']) }
    ]
  },
  preferences: { required },
  meta: [ {}, { required, integer } ],
  labels: [ { required, array, min: min(1) } ],
}

const messages = {
  id: { max: 'id max' },
  preferences: { required: 'preferences required' },
  info: { tags: [ {}, { some: 'info.tags some' } ] },
  meta: [ {}, { integer: 'meta integer' } ],
}

const errors = validate_payload({ payload, rules, messages })

// {
//   id: { max: 'id max' },
//   info: { tags: { '1': { some: 'info.tags some' } } },
//   preferences: { required: 'preferences required' },
//   meta: { '0': { integer: 'meta integer' } },
//   labels: { min: 'min' }
// }

Available Validation Rules

  • required - Field must be present and not empty
  • email - Valid email format
  • integer - Integer number validation
  • numeric - Numeric value validation
  • min / max - Minimum and maximum value constraints
  • min_length / max_length - String length constraints
  • array - Array type validation
  • some - Value must be one of the allowed values
  • string - String type validation
  • boolean - Boolean type validation
  • And many more...

TypeScript Support

Full TypeScript support with comprehensive type definitions for:

  • Validation rules structure
  • Error messages format
  • Nested object validation
  • Array validation patterns

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - feel free to use in commercial projects.


Keywords: validation, validator, typescript, payload, form-validation, api-validation, data-validation, schema-validation, nested-validation, array-validation