1- # Form Validation Library
1+ # Form- Validation- Library JS/TS
22
3- - A comprehensive TypeScript/JavaScript form validation library.
3+ - 🎉 A comprehensive TypeScript/JavaScript form validation library.
44
55[ ![ npm version] ( https://badge.fury.io/js/form-validation-lib-js.svg )] ( https://badge.fury.io/js/form-validation-lib-js )
66[ ![ License: MIT] ( https://img.shields.io/badge/License-MIT-yellow.svg )] ( https://opensource.org/licenses/MIT )
99## Quick Start
1010
1111``` bash
12- npm install form-validatio -lib
12+ npm install form-validation -lib-js
1313
1414```
1515
@@ -23,16 +23,15 @@ npm install form-validatio-lib
2323## Basic Usage
2424
2525``` javascript
26- import { validateEmail , validatePassword , validatePhone , validatePhone_IN } from ' form-validation-lib-js' ;
26+ import { validateEmail , validatePassword , validatePhone_IN } from ' form-validation-lib-js' ;
2727
2828// Email validation
2929const isValidEmail = validateEmail (
' [email protected] ' );
// true3030
3131// Password validation
3232const isValidPassword = validatePassword (' StrongPass1!' ); // true
3333
34- // Phone number validation
35- const isValidPhone = validatePhone (' +1234567890' ); // true
34+ // Phone Number validation
3635const isValdPhone_IN = validatePhone_IN (' +919876543210' ); // true
3736```
3837
@@ -41,11 +40,10 @@ const isValdPhone_IN = validatePhone_IN('+919876543210'); // true
4140import React , { useState } from ' react' ;
4241import { FormValidator } from ' form-validation-lib-js' ;
4342
44- const SignupForm = () => {
43+ const SignInForm = () => {
4544 const [formData , setFormData ] = useState ({
4645 email: ' ' ,
47- password: ' ' ,
48- phone: ' '
46+ password: ' '
4947 });
5048 const [errors , setErrors ] = useState ({});
5149
@@ -56,8 +54,7 @@ const SignupForm = () => {
5654
5755 const validationSchema = {
5856 email: [{ type: ' email' , message: ' Invalid email' }],
59- password: [{ type: ' password' , message: ' Weak password' }],
60- phone: [{ type: ' phone' , message: ' Invalid phone number' }]
57+ password: [{ type: ' password' , message: ' Weak password' }]
6158 };
6259
6360 const result = await validator .validateForm (formData, validationSchema);
@@ -68,7 +65,6 @@ const SignupForm = () => {
6865 }), {}));
6966 return ;
7067 }
71-
7268 // Process form data
7369 };
7470
@@ -78,7 +74,7 @@ const SignupForm = () => {
7874 < input
7975 type= " email"
8076 value= {formData .email }
81- onChange= {(e ) => setFormData ({... formData, email: e .target .value })}
77+ onChange= {(e ) => setFormData ({ ... formData, email: e .target .value })}
8278 / >
8379 {errors .email && < span> {errors .email }< / span> }
8480 < / div>
@@ -87,26 +83,16 @@ const SignupForm = () => {
8783 < input
8884 type= " password"
8985 value= {formData .password }
90- onChange= {(e ) => setFormData ({... formData, password: e .target .value })}
86+ onChange= {(e ) => setFormData ({ ... formData, password: e .target .value })}
9187 / >
9288 {errors .password && < span> {errors .password }< / span> }
9389 < / div>
94-
95- < div>
96- < input
97- type= " text"
98- value= {formData .phone }
99- onChange= {(e ) => setFormData ({... formData, phone: e .target .value })}
100- / >
101- {errors .phone && < span> {errors .phone }< / span> }
102- < / div>
103-
104- < button type= " submit" > Sign Up< / button>
90+ < button type= " submit" > Sign In< / button>
10591 < / form>
10692 );
10793};
10894
109- export default SignupForm ;
95+ export default SignInForm ;
11096```
11197
11298## Custom Validators
@@ -149,11 +135,9 @@ const schema: ValidationSchema = {
149135};
150136```
151137
152- ## Contributing
153- Pull requests are welcome! See ([ CONTRIBUTING.md] ( https://github.com/anuragsingh6886/form-validatio-lib/blob/main/CONTRIBUTING.md ) ) for guidelines.
154-
155- ## Author:
156- - Anurag Singh ([ @anuragsingh6886 ] ( https://www.linkedin.com/in/anuragsingh6886/ ) )
138+ ## Contribute
139+ - Show your ❤️ and support by giving a ⭐
140+ - Pull requests are welcome! See ([ CONTRIBUTING.md] ( https://github.com/anuragsingh6886/form-validatio-lib/blob/main/CONTRIBUTING.md ) ) for guidelines.
157141
158142## License:
159- MIT License - see the ([ LICENSE] ( https://github.com/anuragsingh6886/form-validatio-lib/blob/main/LICENSE ) ) file for details
143+ MIT License - ( [ Anurag Singh ] ( https://x.com/anurags_me ) ), see the ([ LICENSE] ( https://github.com/anuragsingh6886/form-validatio-lib/blob/main/LICENSE ) ) file for details
0 commit comments