ingeni-validation 1.1.17 → 1.1.19
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 +31 -4
- package/package.json +1 -1
package/ingeni-validation.js
CHANGED
|
@@ -89,12 +89,13 @@ async function isNullValue(...params) {
|
|
|
89
89
|
if (param == null) return true;
|
|
90
90
|
|
|
91
91
|
if (typeof param === "string") {
|
|
92
|
-
const
|
|
92
|
+
const trimmed = param.trim().toLowerCase();
|
|
93
93
|
|
|
94
|
+
// reject null-like or only-space strings
|
|
94
95
|
if (
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
trimmed === "" || // covers " "
|
|
97
|
+
trimmed === "null" ||
|
|
98
|
+
trimmed === "undefined"
|
|
98
99
|
) {
|
|
99
100
|
return true;
|
|
100
101
|
}
|
|
@@ -332,6 +333,32 @@ async function isValidDate(value, format) {
|
|
|
332
333
|
return true;
|
|
333
334
|
}
|
|
334
335
|
|
|
336
|
+
|
|
337
|
+
//Validate Gender
|
|
338
|
+
|
|
339
|
+
async function isValidPrice(price){
|
|
340
|
+
if (price === null || price === undefined) return false;
|
|
341
|
+
if (typeof price === "boolean") return false;
|
|
342
|
+
if (typeof price === "string" && price.trim().length === 0) return false;
|
|
343
|
+
if (isNaN(price)) return false;
|
|
344
|
+
if (Number(price) <= 0) return false;
|
|
345
|
+
return true;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
//Validate Gender
|
|
350
|
+
|
|
351
|
+
async function validateGender(gender) {
|
|
352
|
+
if (typeof gender !== "string") return false;
|
|
353
|
+
|
|
354
|
+
const val = gender.trim().toLowerCase();
|
|
355
|
+
|
|
356
|
+
if (val === "" || val === "null" || val === "undefined") return false;
|
|
357
|
+
|
|
358
|
+
return ["m", "f", "male", "female", "other"].includes(val);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
|
|
335
362
|
//Stop details Validation "stop_details":[{"30":["Baripada","13:00","13:01","21.9319,86.7465"]}]
|
|
336
363
|
|
|
337
364
|
async function isValidStopDetails(stop_details){
|