1.0.6 • Published 3 years ago

react-form-field-validation v1.0.6

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

Getting Started with Create React App

import package like this

import {validator} from "react-form-field-validation";

After Installing the package add this function inside your form submit function

const validate= validator();

add an object to the validator function like this.

const validate= validator([ { fieldname: "email", value: UserEmail, rule: "valid-email", "mandatory" }, { fieldname: "password", value: UserPassword, rule: "min-6", "mandatory","max-10", }, ]);

fieldname: which field you need to validate (you need to add the same value provided here as id in the form field)

value: value of that particular field (state variable)

rule: rules need to be added to this key

rule list:

["min-6"]-> field should have atleast 6 characters
["max-10"]-> field can only have maximum of 10 characters
["mandatory"]-> field is a mandatory field
["valid-email"]-> This will check whether the user has given a valid email.
["valid-name"]-> This will check whether the user has given a valid name.
["match-passwords"]-> This will check whether passwords are matching.

Note --> If you are using ["match-passwords"] rule you must give an id as "password" and "confirm-password" to the fields password and confirm password respectively.

You can add rules together like "min-2","max-8","match-password"

once form submit button is clicked the errors will be shown and errors will be updated on the next submit

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago