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

forb

v1.2.0

Published

Lightweight and intuitive form validation library for React applications. Easily manage and validate forms, enhancing user experience and ensuring data accuracy with minimal effort

Downloads

35

Readme

forb - Simplified Form Validation for React

forb is a lightweight and intuitive form validation library for React applications. Easily manage and validate forms, enhancing user experience and ensuring data accuracy with minimal effort.

Installation

You can install the forb library using npm:

npm install forb --save

Or using yarn:

yarn add forb

Usage

  1. Import the necessary components and hooks:
import {
  useForb,
  validator,
  RequiredValidator,
  EmailValidator,
  MaxLengthValidator,
  MinLengthValidator,
  RangeLengthValidator,
  RangeValidator,
  PatternValidator,
} from "forb";
  1. Set up your form and use the useForb hook:
function App() {
  const { validate, register } = useForb();
  const email = useRef("");
  const password = useRef("");

  function handleSubmit(event: FormEvent) {
    event.preventDefault();

    if (!validate()) {
      return;
    }

    console.log("submitted");
  }

  return (
    <form onSubmit={handleSubmit}>
      <div>
        <label>Email</label>
        {register({
          validator:() => validator(email.current, [
            new RequiredValidator("Required"),
            new EmailValidator("Invalid email format"),
          ]),
          render: (errorMessage) => (
            <>
              <input defaultValue={email.current} onChange={(e) => (email.current = e.target.value)} />
              {errorMessage && <>{errorMessage}</>}
            </>
          ),
        })}
      </div>
      <div>
        <label>Password</label>
        {register({
          validator: validator(password.current, [
            new RequiredValidator("Required"),
            new MinLengthValidator(8, "Minimum length is 8 characters"),
          ]),
          render: (errorMessage) => (
            <>
              <input
                type="password"
                defaultValue={password.current}
                onChange={(e) => (password.current = e.target.value)}
              />
              {errorMessage && <>{errorMessage}</>}
            </>
          ),
        })}
      </div>
      <button type="submit">Submit</button>
    </form>
  );
}
  1. Customize your form fields with validation:
  • Use the provided built-in validators (e.g., EmailValidator, MaxLengthValidator, etc.).
  • Create custom validation rules by implementing the Validator abstract class.

API Documentation

useForb

The useForb hook provides the following methods:

  • validate: Validates all registered fields and returns true if all validations pass, otherwise false.

  • register(options): Registers a form field for validation.

validator(value, rules)

The validator function is used to create a validator for a specific form field.

  • value: The value to be validated.
  • rules: An array of validation rules to apply.

Built-in Validators

forb provides the following built-in validators:

  • RequiredValidator: Validates if the field has a non-empty value.

  • EmailValidator: Validates email format.

  • MaxLengthValidator: Validates the maximum length of the value.

  • MinLengthValidator: Validates the minimum length of the value.

  • RangeLengthValidator: Validates the range of the value's length.

  • RangeValidator: Validates the range of numeric values.

  • PatternValidator: Validates against a regular expression pattern.

Custom Validators

You can create custom validation rules by implementing the Validator abstract class.

Contributing

Contributions to forb are welcome! To contribute, please follow the guidelines in CONTRIBUTING.md.

License

This project is licensed under the MIT License - see the LICENSE file for details.