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

auto-form-validator

v1.0.2

Published

A smart, zero-setup form validation library for React with automatic rule detection, i18n support, async validation, and UI integration helpers.

Readme

All Contributors

auto-form-validator

A smart, zero-setup form validation library for React with automatic rule detection, async support, i18n, and UI integration helpers.


Features

  • 🧠 Smart Defaults: Automatically detects validation rules from HTML attributes like required, type, minLength, and more — no need for verbose schemas.
  • ⚙️ Flexible Validation: Supports both inline JSON schema and automatic rule detection from your markup.
  • 🔄 Async Validation: Easily add asynchronous rules such as API checks (e.g., username availability).
  • 🌐 i18n Support: Built-in multi-language error messages, making it easy to internationalize your forms.
  • 💅 UI Helpers: React hooks and components to simplify error handling and display.
  • 🚀 Zero Setup: Get started quickly without writing long Yup or Zod schemas.

Why auto-form-validator?

Traditional validators like Yup or Zod require explicit schema definitions and can add boilerplate, especially for simple forms or dynamic validation needs. Here’s how auto-form-validator stands out:

| Feature | auto-form-validator | Existing Validators (Yup, Zod, Validator.js) | |-------------------------|---------------------------------------|----------------------------------------------------| | Setup | Zero-config rule detection + schemas | Mostly manual, schema-first | | Smart Defaults | Auto-detects from HTML attributes | None | | Async Validation | Built-in support for async API rules | Limited, often complex | | i18n Support | Multi-language errors included | Usually requires separate setup | | UI Integration | React hooks + error display helpers | External integrations required | | Bundle Size & Speed | Lightweight, React-optimized | Bulkier, generic |


How It Works

  • Define an optional validation schema or rely on auto-detected HTML attribute rules.
  • Use the useAutoValidator React hook to register inputs, validate on change or blur, and validate the entire form on submit.
  • Access real-time error messages and form validity status through the hook’s API.
  • Extend with async rules and internationalized error messages easily.

⚡️ Quick Example

import React from "react";
import { useAutoValidator, ErrorMessage } from "auto-form-validator";

export default function SignupForm() {
  const { register, errors, validateForm } = useAutoValidator();

  const handleSubmit = async (e) => {
    e.preventDefault();
    const values = {
      username: e.target.username.value,
      email: e.target.email.value,
    };
    const isValid = await validateForm(values);
    if (isValid) {
      alert("Form valid! Submit logic here.");
    }
  };

  return (
    <form onSubmit={handleSubmit}>
      <input name="username" required minLength={3} {...register("username")} />
      <ErrorMessage name="username" errors={errors} />

      <input name="email" type="email" required {...register("email")} />
      <ErrorMessage name="email" errors={errors} />

      <button type="submit">Register</button>
    </form>
  );
}

🔄 Async Validation

You can create dynamic async validators with helper functions:

import { createUsernameAvailableValidator } from "auto-form-validator/asyncValidators";

const schema = {
  username: {
    required: true,
    async: createUsernameAvailableValidator(async (username) => {
      // Simulate API call
      const taken = ["admin", "mehek"];
      return !taken.includes(username);
    }, "Username is already taken"),
  },
};

🌍 i18n Support

Supports multi-language error messages (default: English + Hindi):

const { register, errors } = useAutoValidator(schema, "hi");

You can also define your own messages:

const customMessages = {
  required: "Custom required message",
  minLength: (n) => `Custom: minimum ${n} chars`,
  maxLength: (n) => `Custom: max ${n} chars`,
  pattern: "Custom pattern failed",
  async: "Custom async failed",
};

Real-World Benefits

  • Less boilerplate: No need to write long Yup/Zod schemas unless you want to.

  • Faster dev experience: Auto-detection reduces setup time.

  • Async & complex validation: Easily add API-backed validations (e.g., username availability).

  • React-friendly: Designed as hooks and UI helpers for React apps.

Contributing & Feedback

Contributions are welcome! Feel free to open issues or PRs. Your feedback helps improve the package.