An open API service indexing awesome lists of open source software.

https://github.com/devnax/react-validex


https://github.com/devnax/react-validex

Last synced: 9 months ago
JSON representation

Awesome Lists containing this project

README

          

# react-validex

> Fast and simple data validator for React

[![NPM](https://img.shields.io/npm/v/react-validex.svg)](https://www.npmjs.com/package/react-validex) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](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