@cloudstrytech/validations 1.0.4 → 1.0.5

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudstrytech/validations",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "JavaScript utility functions for validation",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -6,46 +6,45 @@ import { isValidDate } from "../validators/dateValidator.js";
6
6
  const MANDATORY_FIELDS = {
7
7
  "First name": {
8
8
  message: "First name is required",
9
- validate: (v) => !!v
9
+ validate: (v) => !!v,
10
10
  },
11
11
 
12
12
  "Last name": {
13
13
  message: "Last name is required",
14
- validate: (v) => !!v
14
+ validate: (v) => !!v,
15
15
  },
16
16
 
17
- "email": {
17
+ email: {
18
18
  message: "Email is required or invalid",
19
- validate: (v) => !!v && isValidEmail(v)
19
+ validate: (v) => !!v && isValidEmail(v),
20
20
  },
21
21
 
22
22
  "Mobile Number": {
23
23
  message: "Mobile number is required or invalid",
24
- validate: (v) => !!v && isValidIndianMobile(v)
24
+ validate: (v) => !!v && isValidIndianMobile(v),
25
25
  },
26
26
 
27
- "Company": {
27
+ Company: {
28
28
  message: "Company is required",
29
- validate: (v) => !!v
29
+ validate: (v) => !!v,
30
30
  },
31
31
 
32
- "badge1": {
32
+ badge1: {
33
33
  message: "Badge ID is required or must be a 5-digit number",
34
- validate: (v) => !!v && /^\d{5}$/.test(String(v).trim())
34
+ validate: (v) => !!v && /^\d{5}$/.test(String(v).trim()),
35
35
  },
36
36
 
37
37
  "issuedate-b1": {
38
38
  message: "Issue date is required or invalid",
39
- validate: (v) => !!v && isValidDate(v)
39
+ validate: (v) => !!v && isValidDate(v),
40
40
  },
41
41
 
42
42
  "location-b1": {
43
43
  message: "Location is required",
44
- validate: (v) => !!v
45
- }
44
+ validate: (v) => !!v,
45
+ },
46
46
  };
47
47
 
48
-
49
48
  export async function validateCSV(csvInput) {
50
49
  const rows = await parseCSV(csvInput);
51
50
 
@@ -64,7 +63,7 @@ export async function validateCSV(csvInput) {
64
63
  return {
65
64
  ...row,
66
65
  __status: messages.length > 0 ? "ERROR" : "OK",
67
- __message: messages.length > 0 ? messages.join(", ") : "N/A"
66
+ __messages: messages.length > 0 ? messages : ["N/A"],
68
67
  };
69
68
  });
70
69