@cloudstrytech/validations 1.0.8 → 1.0.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/package.json
CHANGED
package/src/csv/csvValidator.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// csvValidator.js file
|
|
2
|
+
|
|
1
3
|
import { parseCSV } from "./parseCsv";
|
|
2
4
|
import { isValidEmail } from "../validators/emailValidator.js";
|
|
3
5
|
import { isValidIndianMobile } from "../validators/mobileValidator.js";
|
|
@@ -20,7 +22,7 @@ const MANDATORY_FIELDS = {
|
|
|
20
22
|
validate: (v) => !!v && String(v).trim() !== "",
|
|
21
23
|
},
|
|
22
24
|
|
|
23
|
-
|
|
25
|
+
email: {
|
|
24
26
|
message: "Email is required or invalid",
|
|
25
27
|
validate: (v) => !!v && isValidEmail(v),
|
|
26
28
|
},
|
|
@@ -35,10 +37,9 @@ const MANDATORY_FIELDS = {
|
|
|
35
37
|
// validate: (v) => !!v && String(v).trim() !== "",
|
|
36
38
|
// },
|
|
37
39
|
|
|
38
|
-
|
|
40
|
+
badge1: {
|
|
39
41
|
message: "Badge ID is required or must be a 5-digit number",
|
|
40
|
-
validate: (v) =>
|
|
41
|
-
!!v && /^\d{5}$/.test(String(v).trim()),
|
|
42
|
+
validate: (v) => !!v && /^\d{5}$/.test(String(v).trim()),
|
|
42
43
|
},
|
|
43
44
|
|
|
44
45
|
"issuedate-b1": {
|
|
@@ -75,9 +76,9 @@ export async function validateCSV(csvInput) {
|
|
|
75
76
|
}
|
|
76
77
|
|
|
77
78
|
return {
|
|
78
|
-
...row,
|
|
79
|
-
__status: messages.length > 0 ? "ERROR" : "
|
|
80
|
-
__messages: messages.length > 0 ? messages : [
|
|
79
|
+
...row,
|
|
80
|
+
__status: messages.length > 0 ? "ERROR" : "SUCCESS",
|
|
81
|
+
__messages: messages.length > 0 ? messages : [],
|
|
81
82
|
};
|
|
82
83
|
});
|
|
83
84
|
|