react-validex
v1.1.3
Published
Fast and simple data validator for React
Downloads
27
Maintainers
Readme
react-validex
Fast and simple data validator for React
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