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 🙏

© 2025 – Pkg Stats / Ryan Hefner

superform-validator

v2.0.8

Published

A powerful and flexible JavaScript form validator for HTML forms/Express.js.

Downloads

387

Readme

📦 SuperForm Validator

A powerful, flexible, and universal JavaScript form validation library that supports Native HTML Forms, Express.js API validation and React form validation.

npm npm bundle size (version) GitHub release (by tag) jsDelivr hits (npm) npm GitHub issues GitHub closed issues


🚀 Features

| Feature | Supported | | ---------------------------------- | -------------- | | Native HTML Form Validation | ✅ Yes | | Express.js Integration | ✅ Yes | | File Input Validation | ✅ Yes | | Type Casting & Pre/Post Processors | ✅ Yes | | Live Validation Support | ✅ Yes | | Custom Rule Registration | ✅ Yes | | Flexible Error Formatting Engine | ✅ Yes | | TypeScript Ready | ✅ Yes | | React Support | ✅ Yes |


📦 Installation

npm install superform-validator

CDN Usage

<!-- jsDeliver -->
<!-- Latest version -->
<script src="https://cdn.jsdelivr.net/npm/superform-validator@latest/dist/form-validator.js"></script>

<!-- OR -->

<!-- Recommended with specific version -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/form-validator.js"></script>

<!-- OR -->

<!-- unpkg -->
<script src="https://unpkg.com/[email protected]/dist/form-validator.js"></script>

🔄 Quick Examples

HTML Form

const validator = FormValidator.init('#myForm', schema, onValid, onError, options);
validator.enableLiveValidation();

Express Middleware

app.get('/users', expressValidator.validateQuery({
  page: 'require|integer|gt(0)|cast::integer'
}), (req, res) => {
  res.json(req.validated);
});

Error Formatter

const msg = ErrorFormatter.format('Welcome @{user.name || "Guest"}', { user: {} });

📓 Full Documentation


🔄 Live Validation

validator.enableLiveValidation(['blur', 'change', 'input']);

Default events: blur, change.


🔧 Custom Rule Registration

FormValidator.registerRule({
  name: 'isEven',
  paramType: 'none',
  argumentType: 'integer',
  aliases: [],
  validators: [
    {
      callback: (value) => parseInt(value) % 2 === 0,
      message: '@{field} must be an even number'
    }
  ]
}, 'integer');

🔎 Validation Schemas

String Syntax

{
  email: 'require|email|case::lower',
  age: 'require|integer|length(2)|intBetween(10, 15)|cast::integer',
  gender: 'optional|inList(male,female,other,none)|default(none)'
}

Object Syntax with Custom Messages

{
  name: {
    require: true,
    minLength: 2,
    maxLength: 20,
    messages: {
      require: 'Name is required.',
      minLength: 'Name must be at least 2 characters.',
      maxLength: 'Name must be less than 20 characters.'
    }
  }
}

🔒 Validation Rules

Supported rules include:

  • require, minLength, maxLength, length, email, integer, float, mobile
  • file::maxFiles, file::maxSize, file::accepts
  • Pre/Post processors like trim, case::camel, case::upper
  • Casting: cast::integer, cast::boolean, cast::float
  • Full list available in detailed rule reference (coming soon)

Full list of available rules and processors


🔐 Error Placeholder Reference

Supported placeholders:

@{field}
@{param.field}
@{param.value}
@{param}
@{param.min}
@{param.max}
@{param.raw}

Supports advanced formatting with nested access, fallbacks, and string modifiers like upper, lower, capitalize.

Error Formatter Guide


📂 Validation Result Structure

{
  valid: boolean;
  validated: Record<string, any>;
  errors: Record<string, string>;
}

req.validated is available in Express.


🌟 Planned Features

  • 🌐 Multi-language support
  • 👥 Field grouping and nested schema support

💻 Examples


📜 License

Released under the MIT License


👨‍💻 Author

Made with ❤️ by Harshal Khairnar
Founder, Hitraa Technologies
📧 [email protected]