https://github.com/dammy001/react-form-validation-hook
react form validation hook
https://github.com/dammy001/react-form-validation-hook
hooks react react-hooks validation-library validation-rules validations
Last synced: 23 days ago
JSON representation
react form validation hook
- Host: GitHub
- URL: https://github.com/dammy001/react-form-validation-hook
- Owner: dammy001
- License: mit
- Created: 2021-10-01T14:28:51.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2026-01-12T20:28:48.000Z (about 1 month ago)
- Last Synced: 2026-01-13T01:26:27.732Z (about 1 month ago)
- Topics: hooks, react, react-hooks, validation-library, validation-rules, validations
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@damilaredev/react-form-validation-hook
- Size: 1.64 MB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# React Form Validation Hook
### Install
#### NPM
```
npm i @damilaredev/react-form-validation-hook
```
#### Yarn
```
yarn add @damilaredev/react-form-validation-hook
```
### Usage
```javascript
import React, { FC, useState } from 'react';
import useFormValidator from '@damilaredev/react-form-validation-hook'
const Login: FC = () => {
const { values, errors, updateField, isAllFieldsValid } = useFormValidator({
email: {
value: '',
checks: 'required|email', //using pipe to seperate validation rule
},
password: {
value: '',
checks: 'required|digitsBetween:3,5|in:damilare,maxwell,notIn:christiana',
}
});
const submitCredentials = async (e: FormEvent) => {
e.preventDefault();
if (!isAllFieldsValid()) return false;
const { email, password } = values;
};
return (
{errors && {errors[key]}}
)
};
```
## Available validation rules
- required
- email
- numeric
- alphabetic
- alphaNumeric
- maxLength
- minLength
- phone
- url
- size
- in
- digitsBetween
- notIn
- regex
- cardNumber
stay patient more validation rules are coming...