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 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-js-validator

v1.0.12

Published

a simple package for apply input validation on react js validation such as numaric,email,letter,custom rejex,minimum length and max length etc

Downloads

43

Readme

React-js-validator

Component providing simple input validation for react js. use can use validation function directly or custom input for vaildation.

Use Method Directly or Use custom Input listed below

validation Methods:

  • Email
  • Numeric
  • Letter
  • AlphaNumeric
  • CustomRx

custom Input Components:

  • EmailInput
  • LetterInput
  • AlphaNumericInput

Installing

Just simple command npm install command with package name

npm install react-js-validator

Example for Use Method

iimport React, { Component } from 'react';
import Container from '../Containers/Container';
import { Email,Numeric,Letter,AlphaNumeric,CustomRx,Required } from 'react-js-validator'
class HomeComponent extends Component {
  constructor(props) {
    super(props)
    this.state = {
      email: null,
    }; 
  }

  validate() {
    let result = Email(this.state.email);
    console.warn("result", result)
  }
  render() {
    return (
      <div>
        <EmailInput max={10} min={3} />
        <input onBlur={() => this.validate()} onChange={(e) => { this.setState({ email: e.target.value }) }} />
      </div>

    );
  }
}


export default HomeComponent;

Package Functions

Email

| params | Required | Type | Default value | Description | |-----------------|----------|----------|---------------|------------------------------------------------------------------------------------------------------------------------------| | any String | Yes | string | | it will check email valdation and return object with 2 key. 1st msg and 2nd for status. status wil be false if valdation failed. |

Numeric

| params | Required | Type | Default value | Description | |-----------------|----------|----------|---------------|------------------------------------------------------------------------------------------------------------------------------| | any Number | Yes | Number | | it will check Numaric valdation and return object with 2 key. 1st msg and 2nd for status. status wil be false if valdation failed.it must be always 1st param | | min lenght | optional | Number | | it will check minimum length of the number. It must be 2nd parameter.if validation false retruned status will be false. after that if you need only max length than put it null | max lenght | optional | Number | | it will check maximum length of the number. It must be 3nd parameter.if validation false returned status will be false.if you need only max length than put 2nd params null for no minimum length |

Letter

| params | Required | Type | Default value | Description | |-----------------|----------|----------|---------------|------------------------------------------------------------------------------------------------------------------------------| | any string | Yes | String | | it will check Letter valdation and return object with 2 key. 1st msg and 2nd for status. status wil be false if valdation failed. and it must be always 1st param. | | min lenght | optional | Number | | it will check minimum length of the Letter. It must be 2nd parameter.if validation false retruned status will be false. after that if you need only max length than put it null | max lenght | optional | Number | | it will check maximum length of the Letter. It must be 3nd parameter.if validation false returned status will be false.if you need only max length than put 2nd params null for no minimum length |

AlphaNumeric

| params | Required | Type | Default value | Description | |-----------------|----------|----------|---------------|------------------------------------------------------------------------------------------------------------------------------| |any string or number| Yes | String || Number | | it will check AlphaNumeric validation and means it allow letter as well number but not allow special characher and return object with 2 key. 1st msg and 2nd for status. status wil be false if validation failed. and it must be always 1st param.| | min lenght | optional | Number | | it will check minimum length of the AlphaNumeric. It must be 2nd parameter.if validation false retruned status will be false. after that if you need only max length than put it null | max lenght | optional | Number | | it will check maximum length of the AlphaNumeric. It must be 3nd parameter.if validation false returned status will be false.if you need only max length than put 2nd params null for no minimum length |

CustomRx

| params | Required | Type | Default value | Description | |-----------------|----------|----------|---------------|------------------------------------------------------------------------------------------------------------------------------| |any string or number| Yes | String || Number | | it will check AlphaNumeric validation and means it allow letter as well number but not allow special characher and return object with 2 key. 1st msg and 2nd for status. status wil be false if validation failed. and it must be always 1st param.| |special character | optional | bool | | it will check special character in the given value. It must be 2nd parameter.if validation false retruned status will be false.After special character if you need more params than put it null | capital character| optional | bool | | it will check capital character in the given Value. It must be 3nd parameter.if validation false returned status will be false.if you need only capital character params than put 2nd params null for no special length | | min lenght | optional | Number | | it will check minimum length of the AlphaNumeric. It must be 4th parameter.if validation false retruned status will be false. after that if you need only max length than 2nd and 3rd params null | max lenght | optional | Number | | it will check maximum length of the AlphaNumeric. It must be 5th parameter.if validation false returned status will be false.if you need only max length than put 2nd,3rd and 4th params null |

Example for Custom Input Use

import React, { Component } from 'react';
import Container from '../Containers/Container';
import { EmailInput, LetterInput, AlphaNumericInput } from 'react-js-validator'
class HomeComponent extends Component {
  constructor(props) {
    super(props)
    this.state = {
      email: null,
    };
  }
  handleCallback(data) {
    console.warn("status", data)
  }
  render() {
    
    return (
      <div>

        HomeComponent..
        <LetterInput max={10} min={3} return={this.handleCallback.bind(this)} />
       
      </div>

    );
  }
}


export default HomeComponent;

Component props and callback function

LetterInput

| Props | Required | Type | Default value | Description | |-----------------|----------|----------|---------------|------------------------------------------------------------------------------------------------------------------------------| | max | optional | int | null | it will check Input maximum length and return errorStatus true | | min | optional | int | null | it will check Input minimum length and return errorStatus true | | return | optional | callback function | null | it will return the callback status and function should be pass here with a parammeter

EmailInput

| Props | Required | Type | Default value | Description | |-----------------|----------|----------|---------------|------------------------------------------------------------------------------------------------------------------------------| | return | optional | callback function | null | it will return the callback status and function should be pass here with a parammeter |

AlphaNumericInput

| Props | Required | Type | Default value | Description | |-----------------|----------|----------|---------------|------------------------------------------------------------------------------------------------------------------------------| | max | optional | int | null | it will check Input maximum length and return errorStatus true | | min | optional | int | null | it will check Input minimum length and return errorStatus true | | return | optional | callback function | null | it will return the callback status and function should be pass here with a parammeter