ingeni-validation 1.1.3 → 1.1.4

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.
@@ -220,6 +220,33 @@ async function isValidPin(pinCode) {
220
220
  }
221
221
 
222
222
 
223
+ //Valid Date Time (isValidDate(value, "yyyy-mm-dd") , isValidDate(value, "yyyy-mm-dd h:i:s")
224
+ function isValidDate(value, format) {
223
225
 
226
+ let regex;
224
227
 
225
- export {validateMandate,validateOptional, isValidMobile, isValidEmail, isValidOtp, isValidPin,isValidNumber,isValidBoolean,checkBooleanParams};
228
+ switch (format.toLowerCase()) {
229
+
230
+ case "yyyy-mm-dd":
231
+ regex = /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/;
232
+ break;
233
+
234
+ case "yyyy-mm-dd h:i:s":
235
+ regex = /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01]) ([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$/;
236
+ break;
237
+
238
+ default:
239
+ return false;
240
+ }
241
+
242
+ if (!regex.test(value)) {
243
+ return false;
244
+ }
245
+
246
+ const d = new Date(value.replace(" ", "T"));
247
+ return !isNaN(d.getTime());
248
+ }
249
+
250
+
251
+
252
+ export {validateMandate,validateOptional, isValidMobile, isValidEmail, isValidOtp, isValidPin,isValidNumber,isValidBoolean,checkBooleanParams,isValidDate};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ingeni-validation",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "Ingeni Validation",
5
5
  "license": "ISC",
6
6
  "author": "",