ingeni-validation 1.0.9 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ingeni-validation.js +21 -7
- package/package.json +1 -1
package/ingeni-validation.js
CHANGED
|
@@ -91,15 +91,23 @@ async function checkBooleanParams(...params) {
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
|
|
94
|
-
|
|
94
|
+
//Mobile No. Validation
|
|
95
95
|
async function isValidMobile(mobile) {
|
|
96
|
-
|
|
96
|
+
|
|
97
|
+
if (typeof mobile === "boolean" || mobile===null || mobile===undefined) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
|
|
97
101
|
const mobileStr = String(mobile).trim();
|
|
102
|
+
|
|
98
103
|
return /^[0-9]{10}$/.test(mobileStr);
|
|
99
104
|
}
|
|
100
105
|
|
|
101
106
|
|
|
102
107
|
async function isValidEmail(email) {
|
|
108
|
+
if (typeof email === "boolean" || email===null || email===undefined) {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
103
111
|
|
|
104
112
|
const emailStr = String(email).trim();
|
|
105
113
|
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
@@ -112,8 +120,10 @@ async function isValidEmail(email) {
|
|
|
112
120
|
|
|
113
121
|
|
|
114
122
|
async function isValidOtp(otp, otplength) {
|
|
115
|
-
|
|
116
|
-
|
|
123
|
+
if (typeof otp === "boolean" || otp===null || otp===undefined) {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
|
|
117
127
|
if (!Number.isInteger(otplength) || otplength <= 0) return false;
|
|
118
128
|
//console.log("OTPSTR:", otpStr, otpStr.length);
|
|
119
129
|
const otpStr = String(otp).trim();
|
|
@@ -122,7 +132,10 @@ async function isValidOtp(otp, otplength) {
|
|
|
122
132
|
}
|
|
123
133
|
|
|
124
134
|
async function isValidNumber(num, numlength) {
|
|
125
|
-
|
|
135
|
+
|
|
136
|
+
if (typeof num === "boolean" || num===null || num===undefined) {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
126
139
|
|
|
127
140
|
if (!Number.isInteger(numlength) || numlength <= 0) return false;
|
|
128
141
|
|
|
@@ -131,8 +144,9 @@ async function isValidNumber(num, numlength) {
|
|
|
131
144
|
}
|
|
132
145
|
|
|
133
146
|
async function isValidPin(pinCode) {
|
|
134
|
-
if (pinCode ===
|
|
135
|
-
|
|
147
|
+
if (typeof pinCode === "boolean" || pinCode===null || pinCode===undefined) {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
136
150
|
// convert safely to string
|
|
137
151
|
const pinCodeStr = String(pinCode).trim();
|
|
138
152
|
|