ingeni-validation 1.1.12 → 1.1.13

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.
@@ -426,4 +426,39 @@ async function isValidStopDetails(stop_details){
426
426
 
427
427
 
428
428
 
429
- export {validateMandate,validateOptional,isValidMobile,isValidEmail,isValidOtp,isValidPin,isValidNumber,isValidBoolean,checkBooleanParams,isValidDate,isValidTime,isValidPrice,isValidStopDetails};
429
+
430
+ //allow this format only ("20.2849144,85.8078186")
431
+
432
+ function isValidCoordinates(location) {
433
+
434
+ if (location === null || location === undefined) return false;
435
+
436
+ if (typeof location === "boolean") return false;
437
+
438
+ if (typeof location !== "string") return false;
439
+
440
+ if (location.length === 0) return false;
441
+
442
+ if (location.includes(" ")) return false;
443
+
444
+ const regex = /^-?\d{1,2}(\.\d+)?,-?\d{1,3}(\.\d+)?$/;
445
+ if (!regex.test(location)) return false;
446
+
447
+ const [latStr, lngStr] = location.split(",");
448
+
449
+ const lat = Number(latStr);
450
+ const lng = Number(lngStr);
451
+
452
+ // Extra safety
453
+ if (!Number.isFinite(lat) || !Number.isFinite(lng)) return false;
454
+
455
+ if (lat < -90 || lat > 90) return false;
456
+ if (lng < -180 || lng > 180) return false;
457
+
458
+ return true;
459
+ }
460
+
461
+
462
+
463
+
464
+ export {validateMandate,validateOptional,isValidMobile,isValidEmail,isValidOtp,isValidPin,isValidNumber,isValidBoolean,checkBooleanParams,isValidDate,isValidTime,isValidPrice,isValidStopDetails,isValidCoordinates};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ingeni-validation",
3
- "version": "1.1.12",
3
+ "version": "1.1.13",
4
4
  "description": "Ingeni Validation",
5
5
  "license": "ISC",
6
6
  "author": "",