@zohoim/client-sdk 0.0.5-poc01 → 0.0.5-poc02
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.
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
function validateSchemaKeys(schema, data) {
|
|
2
|
+
Object.keys(schema).forEach(key => {
|
|
3
|
+
if (!(key in data)) {
|
|
4
|
+
console.warn(`Key '${key}' is missing in the data`);
|
|
5
|
+
}
|
|
6
|
+
});
|
|
7
|
+
}
|
|
8
8
|
|
|
9
9
|
function isEmpty(value) {
|
|
10
10
|
if (value === null || value === undefined || value === '') {
|
|
@@ -22,7 +22,7 @@ function validateRequiredCheck(_ref) {
|
|
|
22
22
|
} = _ref;
|
|
23
23
|
|
|
24
24
|
if (rules.required && isEmpty(value)) {
|
|
25
|
-
|
|
25
|
+
console.warn(`${path} is required`);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -34,7 +34,7 @@ function validateEnumCheck(_ref2) {
|
|
|
34
34
|
} = _ref2;
|
|
35
35
|
|
|
36
36
|
if (rules.enum && !rules.enum.includes(value)) {
|
|
37
|
-
|
|
37
|
+
console.warn(`${path} must be one of: ${rules.enum.join(', ')}. Received: ${value}`);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
|
@@ -42,8 +42,8 @@ export const validateSchema = (schema, data) => {
|
|
|
42
42
|
const validate = function (schemaObj, dataObj) {
|
|
43
43
|
let path = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
44
44
|
// Check if all schema keys exist in data
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
validateSchemaKeys(schemaObj, dataObj); // Validate each field
|
|
46
|
+
|
|
47
47
|
Object.entries(schemaObj).forEach(_ref3 => {
|
|
48
48
|
let [field, rules] = _ref3;
|
|
49
49
|
const value = dataObj[field];
|