@truedat/df 8.0.2 → 8.0.3
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": "@truedat/df",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.3",
|
|
4
4
|
"description": "Truedat Web Data Quality Module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"module": "src/index.js",
|
|
@@ -48,14 +48,14 @@
|
|
|
48
48
|
"@testing-library/jest-dom": "^6.6.3",
|
|
49
49
|
"@testing-library/react": "^16.3.0",
|
|
50
50
|
"@testing-library/user-event": "^14.6.1",
|
|
51
|
-
"@truedat/test": "8.0.
|
|
51
|
+
"@truedat/test": "8.0.3",
|
|
52
52
|
"identity-obj-proxy": "^3.0.0",
|
|
53
53
|
"jest": "^29.7.0",
|
|
54
54
|
"redux-saga-test-plan": "^4.0.6"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"@apollo/client": "^3.13.8",
|
|
58
|
-
"@truedat/core": "8.0.
|
|
58
|
+
"@truedat/core": "8.0.3",
|
|
59
59
|
"axios": "^1.12.0",
|
|
60
60
|
"graphql": "^16.11.0",
|
|
61
61
|
"is-hotkey": "^0.2.0",
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"semantic-ui-react": "^3.0.0-beta.2",
|
|
85
85
|
"swr": "^2.3.3"
|
|
86
86
|
},
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "5be7b14325000a19bb8f18a96dff0bc16757745b"
|
|
88
88
|
}
|
|
@@ -3,14 +3,14 @@ import { flattenFields } from "./flattenFields";
|
|
|
3
3
|
|
|
4
4
|
const fieldIsHiddenVerifier =
|
|
5
5
|
(content) =>
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
({ depends }) => {
|
|
7
|
+
if (!depends) return false;
|
|
8
|
+
const { on, to_be } = depends;
|
|
9
|
+
const dependentValue = content[on]?.value || content[on] || undefined;
|
|
10
|
+
return _.isArray(dependentValue)
|
|
11
|
+
? !_.some((d) => to_be.includes(d))(dependentValue)
|
|
12
|
+
: !to_be.includes(dependentValue);
|
|
13
|
+
};
|
|
14
14
|
|
|
15
15
|
const isTableRequired = (field, content) => {
|
|
16
16
|
if (field?.type === "dynamic_table" && _.has("values.table_columns")(field)) {
|
|
@@ -20,25 +20,26 @@ const isTableRequired = (field, content) => {
|
|
|
20
20
|
|
|
21
21
|
return _.flow(
|
|
22
22
|
_.pathOr([], "values.table_columns"),
|
|
23
|
-
_.any((nestedField) => _.includes(nestedField?.cardinality)(["1", "+"]))
|
|
24
|
-
|
|
23
|
+
_.any((nestedField) => _.includes(nestedField?.cardinality)(["1", "+"]))
|
|
24
|
+
)(field);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
return false;
|
|
28
|
-
}
|
|
28
|
+
};
|
|
29
29
|
|
|
30
30
|
const validateTemplateContent = (schema, content) => {
|
|
31
31
|
const fieldIsHidden = fieldIsHiddenVerifier(content);
|
|
32
32
|
const templateContent = _.reject(fieldIsHidden)(schema);
|
|
33
33
|
return _.flow(validateRequired(templateContent), _.head)([[], content]);
|
|
34
|
-
}
|
|
34
|
+
};
|
|
35
35
|
|
|
36
36
|
export const validateContent = (template) => (content) => {
|
|
37
37
|
const schema = flattenFields(template);
|
|
38
38
|
return validateTemplateContent(schema, content);
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
const isEmptyValue = (value) =>
|
|
41
|
+
const isEmptyValue = (value) =>
|
|
42
|
+
_.isNil(value) || (!_.isNumber(value) && _.isEmpty(value));
|
|
42
43
|
|
|
43
44
|
const isEmptyField = (field, content) => {
|
|
44
45
|
if (field?.type === "dynamic_table" && _.has("values.table_columns")(field)) {
|
|
@@ -49,29 +50,29 @@ const isEmptyField = (field, content) => {
|
|
|
49
50
|
|
|
50
51
|
const requiredErrors = _.flow(
|
|
51
52
|
_.map((row) => _.flow(validateRequired(tableColumns), _.head)([[], row])),
|
|
52
|
-
_.flatten
|
|
53
|
+
_.flatten
|
|
53
54
|
)(rowValues);
|
|
54
55
|
|
|
55
56
|
return !_.isEmpty(requiredErrors);
|
|
56
57
|
}
|
|
57
58
|
return isEmptyValue(content?.[field?.name]?.value);
|
|
58
|
-
}
|
|
59
|
+
};
|
|
59
60
|
|
|
60
61
|
export const validateRequired =
|
|
61
62
|
(templateContent) =>
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
63
|
+
([validations, content]) => {
|
|
64
|
+
const newValidations = _.flow([
|
|
65
|
+
_.filter((field) => isRequired(field, content)),
|
|
66
|
+
_.filter((field) => isEmptyField(field, content)),
|
|
67
|
+
_.map((field) => ({ error: "missing required", field: field?.name })),
|
|
68
|
+
])(templateContent);
|
|
69
|
+
return [[...validations, ...newValidations], content];
|
|
70
|
+
};
|
|
70
71
|
|
|
71
72
|
export const dependentRequired = (field, content) => {
|
|
72
73
|
if (_.has("mandatory")(field)) {
|
|
73
74
|
const on = field?.mandatory?.on;
|
|
74
|
-
const dependent = content[on]?.value;
|
|
75
|
+
const dependent = content[on]?.value || content[on] || undefined;
|
|
75
76
|
const target = field?.mandatory?.to_be || [];
|
|
76
77
|
if (_.isArray(dependent)) {
|
|
77
78
|
return !_.isEmpty(_.intersection(dependent)(target));
|
|
@@ -83,7 +84,8 @@ export const dependentRequired = (field, content) => {
|
|
|
83
84
|
};
|
|
84
85
|
|
|
85
86
|
export const isRequired = (field, content) =>
|
|
86
|
-
_.includes(field?.cardinality)(["1", "+"]) ||
|
|
87
|
+
_.includes(field?.cardinality)(["1", "+"]) ||
|
|
88
|
+
isTableRequired(field, content) ||
|
|
87
89
|
dependentRequired(field, content);
|
|
88
90
|
|
|
89
91
|
export const enrichRequired = (content) => (field) => {
|
|
@@ -91,13 +93,13 @@ export const enrichRequired = (content) => (field) => {
|
|
|
91
93
|
if (field?.type === "dynamic_table" && _.has("values.table_columns")(field)) {
|
|
92
94
|
const tableColumns = _.flow(
|
|
93
95
|
_.propOr([], "values.table_columns"),
|
|
94
|
-
_.map((field) => enrichRequired({})(field))
|
|
95
|
-
|
|
96
|
+
_.map((field) => enrichRequired({})(field))
|
|
97
|
+
)(field);
|
|
96
98
|
|
|
97
99
|
return _.flow(
|
|
98
100
|
_.set("values.table_columns", tableColumns),
|
|
99
|
-
_.set("required", required)
|
|
100
|
-
|
|
101
|
+
_.set("required", required)
|
|
102
|
+
)(field);
|
|
101
103
|
}
|
|
102
104
|
|
|
103
105
|
return { ...field, required };
|