react-validex
TypeScript icon, indicating that this package has built-in type declarations

1.1.3 • Public • Published

react-validex

Fast and simple data validator for React

NPM JavaScript Style Guide

Install

npm install --save react-validex

Usage

import {withValidator, ValidField} from 'react-validex'

const Form = ({validator}) => {

  const [state, setState] = useState({
    user_name: ''
  })

  useEffect(() => {
    validator.validate()
  }, [state])

  return <div>
    <ValidField
      nameAlias="User Name"
      name="user_name"
      value={state.user_name}
      validator={validator}
      showError
      min={6}
      max={15}
    >
      <input type="text" value={state.user_name} onChange={(e) => setState({...state, user_name: e.target.value})}/>
    </ValidField>
  </div>
}

export default withValidator(Form)

Props

Name Description
children element required
validator validator instance required
name field name required
value field value required
showError show the error bellow boolean

Please follow the validex for the validator props

Package Sidebar

Install

npm i react-validex

Weekly Downloads

0

Version

1.1.3

License

MIT

Unpacked Size

269 kB

Total Files

7

Last publish

Collaborators

  • devnax