ingeni-validation 1.1.8 → 1.1.9
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 +13 -13
- package/package.json +1 -1
package/ingeni-validation.js
CHANGED
|
@@ -310,7 +310,7 @@ async function isValidDate(value, format) {
|
|
|
310
310
|
|
|
311
311
|
//Stop details Validation "stop_details":[{"30":["Baripada","13:00","13:01","21.9319,86.7465"]}]
|
|
312
312
|
|
|
313
|
-
|
|
313
|
+
async function isValidStopDetails(stop_details){
|
|
314
314
|
|
|
315
315
|
if (!Array.isArray(stop_details) || stop_details.length === 0){
|
|
316
316
|
return false;
|
|
@@ -339,7 +339,6 @@ async function isValidDate(value, format) {
|
|
|
339
339
|
|
|
340
340
|
const stop_id = keys[0];
|
|
341
341
|
|
|
342
|
-
// stop id must be numeric
|
|
343
342
|
if (!/^\d+$/.test(stop_id)){
|
|
344
343
|
return false;
|
|
345
344
|
}
|
|
@@ -352,30 +351,31 @@ async function isValidDate(value, format) {
|
|
|
352
351
|
|
|
353
352
|
let [stop_name, arrival_time, departure_time, latlong] = values;
|
|
354
353
|
|
|
355
|
-
// stop name
|
|
356
354
|
if (typeof stop_name !== "string" || stop_name.trim().length === 0){
|
|
357
355
|
return false;
|
|
358
356
|
}
|
|
359
357
|
|
|
360
|
-
// time validation
|
|
361
358
|
if (!timeRegex.test(arrival_time) || !timeRegex.test(departure_time)){
|
|
362
359
|
return false;
|
|
363
360
|
}
|
|
364
361
|
|
|
365
|
-
//
|
|
366
|
-
if (toMinutes(arrival_time)
|
|
362
|
+
// allow equal time
|
|
363
|
+
if (toMinutes(arrival_time) > toMinutes(departure_time)){
|
|
367
364
|
return false;
|
|
368
365
|
}
|
|
369
366
|
|
|
370
|
-
// lat,long
|
|
371
|
-
if (
|
|
372
|
-
|
|
373
|
-
|
|
367
|
+
// lat,long optional
|
|
368
|
+
if (latlong !== ""){
|
|
369
|
+
|
|
370
|
+
if (typeof latlong !== "string" || !latlongRegex.test(latlong)){
|
|
371
|
+
return false;
|
|
372
|
+
}
|
|
374
373
|
|
|
375
|
-
|
|
374
|
+
let [lat, lon] = latlong.split(",").map(Number);
|
|
376
375
|
|
|
377
|
-
|
|
378
|
-
|
|
376
|
+
if (lat < -90 || lat > 90) return false;
|
|
377
|
+
if (lon < -180 || lon > 180) return false;
|
|
378
|
+
}
|
|
379
379
|
|
|
380
380
|
}
|
|
381
381
|
|