react-validation-hook
React hook for sync and async validation in forms
Website
Visit the website for demo and docs
Features
- Nice and Easy hook based interface
- Supports both Synchronous and Asynchronous validation
- Supports validators like range, required, length, regex out of the box
- Specify custom validators!
- Out of the box formatted error messages, which could be overwritten
Install
npm install --save react-validation-hook
Usage
import React useEffect from "react"; import useValidator requiredValidation lengthValidation asyncValidation from "react-validation-hook"; const asyncFunction = const response = await ; const res = await response; if valuelength < 3 throw "Custom error " + value; ; const validators = ; const error onChange pending = ; const changeHandler = { console; }; return <div> <ul> error </ul> <input = /> </div> ;;
License
MIT © sumedh22