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

react-input-validator

v1.2.0

Published

react-input-validator is input super class validator

Readme

Intro

react-input-validator is a light input SUPER class validator, a clever container for pattern matches, which is so light without any special dependencies at all, The main file is InputValidator.js which is included inside InputValidator folder, and that class is an instance of React.component class which is responsible for appending classes for the current state of the input.

Usage

You need to extends this small class and just write your own pattern logic, and the SUPER class will handle the validation status, and will verify from the entered value for every "change" by depending on the passed REQUIRED function from the outside world through the prop onInputChange, and to pass the REQUIRED params which is (nodeElement, PatternValidatorFn) .

States

There are 4 basic states for the input (can be grapped by super.getValidationClass Fn):

  • sn-valid: which indicates that the input is valid
  • sn-not-valid: which indicates that the input is not valid
  • sn-dirty: which indicates that the input is dirty
  • sn-loading: which indicates that the input is loading (checking pattern)

Validation timer

The validation is checked when the user has stopped writing for one complete second to follow the UI principles (In the meanwhile the sn-loading will be revealed into super.getValidationClass() method)

Install

Running Examples

Then go to: file:///{Your Path}/react-input-validator/Client/index.html

Example (See Examples folder for more implementations examples)

import InputValidator from 'react-input-validator';

class PhoneInput extends InputValidator {

    constructor(props) {
        super(props);
    }

    render() {
        return (
            <div className={'relative-pos form-group' + super.getValidationClass()}>
                <label htmlFor="phone-input">Phone Number:</label>
                <input type="text"
                       ref={node => this.phoneRef = node}
                       onChange={() => { super.onInputChange(this.phoneRef, this.validatePhone) }}
                       className="form-control" id="phone-input" />
                <i className="hidden fa fa-spin fa-spinner"></i>
            </div>
        )
    }

    validatePhone() {
        //Pattern: xxx-xxxxxxx || xxxxxxxxxx
        let phoneRegex = /^[0-9][0-9][0-9](-?)[0-9][0-9][0-9][0-9][0-9][0-9][0-9]$/;
        if(phoneRegex.test(this.phoneRef.value)) {
            return true;
        } else if (!phoneRegex.test(this.phoneRef.value)) {
            return false;
        }
    }

}


export default PhoneInput;