1.0.12 • Published 6 years ago

react-js-validator v1.0.12

Weekly downloads
1
License
ISC
Repository
-
Last release
6 years ago

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

paramsRequiredTypeDefault valueDescription
any StringYesstringit will check email valdation and return object with 2 key. 1st msg and 2nd for status. status wil be false if valdation failed.

Numeric

paramsRequiredTypeDefault valueDescription
any NumberYesNumberit 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 lenghtoptionalNumberit 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 lenghtoptionalNumberit 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

paramsRequiredTypeDefault valueDescription
any stringYesStringit 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 lenghtoptionalNumberit 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 lenghtoptionalNumberit 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

paramsRequiredTypeDefault valueDescription
any string or numberYesStringNumberit 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 lenghtoptionalNumberit 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 lenghtoptionalNumberit 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

paramsRequiredTypeDefault valueDescription
any string or numberYesStringNumberit 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 characteroptionalboolit 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 characteroptionalboolit 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 lenghtoptionalNumberit 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 lenghtoptionalNumberit 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

PropsRequiredTypeDefault valueDescription
maxoptionalintnullit will check Input maximum length and return errorStatus true
minoptionalintnullit will check Input minimum length and return errorStatus true
returnoptionalcallback functionnullit will return the callback status and function should be pass here with a parammeter

EmailInput

PropsRequiredTypeDefault valueDescription
returnoptionalcallback functionnullit will return the callback status and function should be pass here with a parammeter

AlphaNumericInput

PropsRequiredTypeDefault valueDescription
maxoptionalintnullit will check Input maximum length and return errorStatus true
minoptionalintnullit will check Input minimum length and return errorStatus true
returnoptionalcallback functionnullit will return the callback status and function should be pass here with a parammeter
1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.0

6 years ago

1.0.1

6 years ago