Skip to content

Commit ab208da

Browse files
bug fix lib
1 parent 67a785f commit ab208da

File tree

12 files changed

+25
-27
lines changed

12 files changed

+25
-27
lines changed

dist/cjs/validators/creditCardValidator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @param creditCardNumber - The credit card number to validate
44
* @returns boolean - True if the credit card number is valid
55
*/
6-
export function validateCreditCardNumber(creditCardNumber) {
6+
export function validateCreditCard(creditCardNumber) {
77
// Input validation
88
if (!creditCardNumber || typeof creditCardNumber !== 'string') {
99
return false;

dist/cjs/validators/emailValidator.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export function validateEmail(email) {
88
if (!email || typeof email !== 'string') {
99
return false;
1010
}
11-
// RFC 5322 compliant email regex
12-
const re = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
13-
return re.test(email.toLowerCase());
11+
// email regex
12+
const regex = /^([a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6})*$/;
13+
return regex.test(email.toLowerCase());
1414
}

dist/esm/validators/creditCardValidator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @param creditCardNumber - The credit card number to validate
44
* @returns boolean - True if the credit card number is valid
55
*/
6-
export function validateCreditCardNumber(creditCardNumber) {
6+
export function validateCreditCard(creditCardNumber) {
77
// Input validation
88
if (!creditCardNumber || typeof creditCardNumber !== 'string') {
99
return false;

dist/esm/validators/emailValidator.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export function validateEmail(email) {
88
if (!email || typeof email !== 'string') {
99
return false;
1010
}
11-
// RFC 5322 compliant email regex
12-
const re = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
13-
return re.test(email.toLowerCase());
11+
// email regex
12+
const regex = /^([a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6})*$/;
13+
return regex.test(email.toLowerCase());
1414
}

dist/types/validators/creditCardValidator.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
* @param creditCardNumber - The credit card number to validate
44
* @returns boolean - True if the credit card number is valid
55
*/
6-
export declare function validateCreditCardNumber(creditCardNumber: string): boolean;
6+
export declare function validateCreditCard(creditCardNumber: string): boolean;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "form-validation-lib-js",
3-
"version": "2.1.3",
3+
"version": "2.1.4",
44
"type": "module",
55
"description": "A comprehensive JavaScript form validation library",
66
"main": "./dist/cjs/index.js",

src/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ export interface ValidationSchema {
1919
[field: string]: ValidationRule[];
2020
}
2121

22-
export type ValidatorFunction = (value: any, options?: any) => boolean;
23-
export type AsyncValidatorFunction = (value: any, options?: any) => Promise<boolean>;
22+
export type ValidatorFunction = (value: any, options?: any) => boolean; // eslint-disable-line
23+
export type AsyncValidatorFunction = (value: any, options?: any) => Promise<boolean>; // eslint-disable-line

src/validators/creditCardValidator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @param creditCardNumber - The credit card number to validate
44
* @returns boolean - True if the credit card number is valid
55
*/
6-
export function validateCreditCardNumber(creditCardNumber: string): boolean {
6+
export function validateCreditCard(creditCardNumber: string): boolean {
77
// Input validation
88
if (!creditCardNumber || typeof creditCardNumber !== 'string') {
99
return false;

src/validators/emailValidator.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export function validateEmail(email: string): boolean {
99
return false;
1010
}
1111

12-
// RFC 5322 compliant email regex
13-
const re = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
14-
return re.test(email.toLowerCase());
12+
// email regex
13+
const regex = /^([a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6})*$/;
14+
return regex.test(email.toLowerCase());
1515
}

src/validators/phoneNumberValidator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export function validatePhone_US(phoneNumber: string): boolean {
1717

1818
export function validatePhone_IN(phoneNumber: string): boolean {
1919
if (!phoneNumber || typeof phoneNumber !== 'string') return false;
20-
const regex = /^(\+91[\-\s]?)?[0]?(91)?[789]\d{9}$/;
20+
const regex = /^(\+91[-\s]?)?[0]?(91)?[789]\d{9}$/;
2121
return regex.test(String(phoneNumber));
2222
}
2323

0 commit comments

Comments
 (0)