ingeni-validation 1.0.4 → 1.0.6

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.
@@ -87,17 +87,27 @@ async function isValidEmail(email) {
87
87
  }
88
88
 
89
89
 
90
- async function isValidOtp(otp) {
91
- if (otp === undefined || otp === null) return false;
92
90
 
93
- const otpStr = String(otp).trim();
94
91
 
95
- if (otpStr.length !== 6) return false;
96
92
 
97
- return /^[0-9]{6}$/.test(otpStr);
93
+ async function isValidOtp(otp, otplength) {
94
+ if (otp === undefined || otp === null) return false;
95
+
96
+ if (!Number.isInteger(otplength) || otplength <= 0) return false;
97
+ //console.log("OTPSTR:", otpStr, otpStr.length);
98
+ const otpStr = String(otp).trim();
99
+
100
+ return new RegExp(`^[0-9]{${otplength}}$`).test(otpStr);
101
+ }
102
+
103
+ async function isValidNumber(num, numlength) {
104
+ if (num === undefined || num === null) return false;
105
+
106
+ if (!Number.isInteger(numlength) || numlength <= 0) return false;
107
+
108
+ const numStr = String(num).trim();
109
+ return new RegExp(`^[0-9]{${numlength}}$`).test(numStr);
98
110
  }
99
-
100
-
101
111
 
102
112
  async function isValidPin(pinCode) {
103
113
  if (pinCode === undefined || pinCode === null) return false;
@@ -111,7 +121,4 @@ async function isValidPin(pinCode) {
111
121
  return /^[0-9]{6}$/.test(pinCodeStr);
112
122
  }
113
123
 
114
-
115
-
116
-
117
- export {validateMandate,validateOptional, isValidMobile, isValidEmail, isValidOtp, isValidPin };
124
+ export {validateMandate,validateOptional, isValidMobile, isValidEmail, isValidOtp, isValidPin,isValidNumber};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ingeni-validation",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Ingeni Validation",
5
5
  "license": "ISC",
6
6
  "author": "",