@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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudstrytech/validations",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "JavaScript utility functions for validation",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -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
- "email": {
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
- "badge1": {
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, // keep original CSV data for UI table
79
- __status: messages.length > 0 ? "ERROR" : "OK",
80
- __messages: messages.length > 0 ? messages : ["N/A"],
79
+ ...row,
80
+ __status: messages.length > 0 ? "ERROR" : "SUCCESS",
81
+ __messages: messages.length > 0 ? messages : [],
81
82
  };
82
83
  });
83
84
 
@@ -0,0 +1,7 @@
1
+ // nameValidator.js
2
+ export function isValidName(name) {
3
+ if (!name) return false;
4
+
5
+ const regex = /^[A-Za-z]+(?:\s[A-Za-z]+)*$/;
6
+ return regex.test(name.trim());
7
+ }