@legalplace/wizardx-core 4.4.3 → 4.5.0
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,3 +1,4 @@
|
|
|
1
|
+
import { EMAIL_REGEX } from "../../constants/emailValidation";
|
|
1
2
|
import { UPDATE_OPTION_INPUT, UPDATE_VARIABLE_INPUT, ADD_MULTIPLE_OCCURENCY, DELETE_MULTIPLE_OCCURENCY, } from "../constants/inputs";
|
|
2
3
|
import { selectVariableInputByIndex, selectOptionInputByIndex, selectOptionInput, } from "../selectors/inputs";
|
|
3
4
|
import { SET_MANDATORY_OPTION, SET_MANDATORY_VARIABLE, } from "../constants/mandatories";
|
|
@@ -5,7 +6,7 @@ import { selectOptionRelations, selectOptionReference, selectSectionReference, s
|
|
|
5
6
|
import { selectMandatoryOption, selectMandatoryVariable, } from "../selectors/mandatories";
|
|
6
7
|
import { setMandatoryOptionAction, setMandatorySectionAction, setMandatoryVariableAction, } from "../actions/mandatories";
|
|
7
8
|
import { UPDATE_OPTION_CONDITION, UPDATE_VARIABLE_CONDITION, UPDATE_SECTION_CONDITION, } from "../constants/conditions";
|
|
8
|
-
import { selectOptionConditionValue, selectVariableConditionValue, selectIsOptionDisplayed, selectIsVariableDisplayed, } from "../selectors/conditions";
|
|
9
|
+
import { selectOptionConditionValue, selectVariableConditionValue, selectIsOptionDisplayed, selectIsVariableDisplayed, selectVariableValidatorConditionValue, } from "../selectors/conditions";
|
|
9
10
|
import { FETCH_MODEL_SUCCEEDED } from "../constants/app";
|
|
10
11
|
import { checkDateValidity } from "../../helpers/date.helper";
|
|
11
12
|
import { checkPhoneNumberValidity } from "../../helpers/phoneNumber.helper";
|
|
@@ -120,6 +121,7 @@ const watchSectionMandatory = (mpi, next, action) => {
|
|
|
120
121
|
validateSectionMandatory(mpi, sectionId);
|
|
121
122
|
};
|
|
122
123
|
const watchUpdateVariableInputCondition = (mpi, next, action, ignoreNext) => {
|
|
124
|
+
var _a;
|
|
123
125
|
const { type, id, index, value } = action;
|
|
124
126
|
if (ignoreNext !== true)
|
|
125
127
|
next(action);
|
|
@@ -128,19 +130,29 @@ const watchUpdateVariableInputCondition = (mpi, next, action, ignoreNext) => {
|
|
|
128
130
|
const inputValue = type === UPDATE_VARIABLE_INPUT
|
|
129
131
|
? `${value}`.trim().length > 0
|
|
130
132
|
: `${selectVariableInputByIndex(id, index)}`.trim().length > 0;
|
|
131
|
-
const { type: variableType } = selectVariableReference(id);
|
|
133
|
+
const { type: variableType, mask } = selectVariableReference(id);
|
|
132
134
|
const conditionValue = action.type === UPDATE_VARIABLE_CONDITION
|
|
133
135
|
? action.value
|
|
134
136
|
: selectVariableConditionValue(id, index) !== false;
|
|
135
137
|
let mandatoryValue = !conditionValue || (conditionValue && inputValue);
|
|
136
|
-
|
|
138
|
+
const emailInvalidCheck = (variableType === "email" || variableType === "user_email") &&
|
|
137
139
|
typeof value === "string" &&
|
|
138
|
-
!
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
140
|
+
!EMAIL_REGEX.test(value.toString());
|
|
141
|
+
const dateInvalidCheck = variableType === "date" &&
|
|
142
|
+
typeof value === "string" &&
|
|
143
|
+
!checkDateValidity(value);
|
|
144
|
+
const phoneNumberInvalidCheck = variableType === "phone_number" &&
|
|
145
|
+
typeof value === "string" &&
|
|
146
|
+
!checkPhoneNumberValidity(value);
|
|
147
|
+
const maskInvalidityCheck = variableType === "mask" &&
|
|
142
148
|
typeof value === "string" &&
|
|
143
|
-
!
|
|
149
|
+
!(value.toString().trim().length === ((_a = mask === null || mask === void 0 ? void 0 : mask.formula) === null || _a === void 0 ? void 0 : _a.length));
|
|
150
|
+
const customValidatorInvalidCheck = selectVariableValidatorConditionValue(id, index) === false;
|
|
151
|
+
if (emailInvalidCheck ||
|
|
152
|
+
dateInvalidCheck ||
|
|
153
|
+
phoneNumberInvalidCheck ||
|
|
154
|
+
maskInvalidityCheck ||
|
|
155
|
+
customValidatorInvalidCheck) {
|
|
144
156
|
mandatoryValue = false;
|
|
145
157
|
}
|
|
146
158
|
mpi.dispatch(setMandatoryVariableAction(id, index, mandatoryValue));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legalplace/wizardx-core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0",
|
|
4
4
|
"author": "Moncef Hammou (moncef@legalplace.fr)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
"@legalplace/lp-events": "1.14.0",
|
|
25
25
|
"@legalplace/lplogic": "^2.1.6",
|
|
26
26
|
"@legalplace/model-healthcheck": "^1.1.5",
|
|
27
|
-
"@legalplace/referencesparser": "^3.0.
|
|
27
|
+
"@legalplace/referencesparser": "^3.0.5",
|
|
28
28
|
"@legalplace/storybook": "^2.171.0",
|
|
29
|
-
"@legalplace/typeorm-constants": "^3.
|
|
29
|
+
"@legalplace/typeorm-constants": "^3.19.0",
|
|
30
30
|
"@loadable/component": "^5.15.0",
|
|
31
31
|
"@redux-saga/core": "^1.1.3",
|
|
32
32
|
"connected-react-router": "^6.8.0",
|
|
@@ -55,9 +55,9 @@
|
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@legalplace/eslint-config": "^2.2.0",
|
|
58
|
-
"@legalplace/models-v3-types": "^5.1.
|
|
58
|
+
"@legalplace/models-v3-types": "^5.1.21",
|
|
59
59
|
"@legalplace/prettier-config": "^2.1.3",
|
|
60
|
-
"@legalplace/typeorm-entities": "^5.
|
|
60
|
+
"@legalplace/typeorm-entities": "^5.24.0",
|
|
61
61
|
"@swc-node/jest": "^1.3.2",
|
|
62
62
|
"@swc/core": "^1.2.93",
|
|
63
63
|
"@swc/jest": "^0.2.4",
|
|
@@ -95,5 +95,5 @@
|
|
|
95
95
|
"*.test.ts",
|
|
96
96
|
"*.test.tsx"
|
|
97
97
|
],
|
|
98
|
-
"gitHead": "
|
|
98
|
+
"gitHead": "c8d086ebb96ba3f5c61b81b2d297bfb06a24e9d6"
|
|
99
99
|
}
|