recassfov
React Client and Server Side Form Validation
Usage
Install library.
# with yarn $ yarn add recassfov # or with npm $ npm i recassfov
Import library.
import Form Input from 'recassfov'
Create validation rules. (Validator.js)
const validations = username: rule: 'isLength' args: min: 4 max: 32 invalidFeedback: 'please provide a username (min: 4, max: 32)' email: rule: 'isEmail' invalidFeedback: 'please provide a valid email' message: rule: 'isLength' args: min: 1 invalidFeedback: 'please provide a message'
Build your form.
<Form ='http://site.com/post'> <div> <Input ='text' ='username' ='username' = /> </div> <div> <Input ='email' ='email' ='email' = /> </div> <div> <Textarea ='message' ='message' = /> </div> <div> <input ='submit' ='submit' /> </div></Form>
Add .is-invalid
and .invalid-feedback
classes into your CSS.
Make sure you add the errors to the validations
object in backend.
app
Props & Callbacks
<Form>
Props
<Form ='http://site.com.post' = = >
Callbacks
<Form = = = = = >
Contribution
Feel free to contribute. Open a new issue, or make a pull request.