simple-react-validator-hooks
v1.0.0
Published
### Usage 1. Initialize the validator ``` const [validator, showValidationMessage] = useValidator(customMessages, customValidator) ```
Downloads
91
Readme
Use of SimpleReactValidator in functional component using Hooks
Usage
- Initialize the validator
const [validator, showValidationMessage] = useValidator(customMessages, customValidator)
- Add validation rules under inputs
validator.message('password', password, 'required')
- Check if validation passes and turn on message
if (validator.allValid()) {
console.log('Submit Data')
} else {
// turn on validation message and re-render
showValidationMessage(true)
}