validate-your-react
v1.0.1
Published
input field validation
Downloads
11
Maintainers
Readme
Project Name
A package to validate your React form.
Prerequisites
This project requires NodeJS (version 8 or later), NPM, and React project.
Getting Started
To install and set up the library, run:
$ npm install validate-your-react
Usage
basic validation
import { object } from "validate-your-react";
const userSchema = object({
email: ["string", "required", "email"],
password: ["string", "required", "min=6"],
//...
});
const result = userSchema.validate({email:"[email protected]", password:"testpass"});
setErrors(result.errors);
return result.valid;
/*
* result = {
* errors:{email:"email is required"}
* valid:false
* }
* */
Contributing
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Add your changes:
git add .
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :sunglasses: