react-validex

Fast and simple data validator for React

Usage no npm install needed!

<script type="module">
  import reactValidex from 'https://cdn.skypack.dev/react-validex';
</script>

README

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