https://github.com/devnax/react-validex
https://github.com/devnax/react-validex
Last synced: 9 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/devnax/react-validex
- Owner: devnax
- Created: 2022-01-01T08:34:14.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-02-27T09:44:44.000Z (over 4 years ago)
- Last Synced: 2025-01-22T00:41:25.397Z (over 1 year ago)
- Language: JavaScript
- Size: 1.59 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# react-validex
> Fast and simple data validator for React
[](https://www.npmjs.com/package/react-validex) [](https://standardjs.com)
## Install
```bash
npm install --save react-validex
```
## Usage
```jsx
import {withValidator, ValidField} from 'react-validex'
const Form = ({validator}) => {
const [state, setState] = useState({
user_name: ''
})
useEffect(() => {
validator.validate()
}, [state])
return
setState({...state, user_name: e.target.value})}/>
}
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](https://www.npmjs.com/package/validex) for the validator props