@processmaker/screen-builder 3.8.38 → 3.8.39
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
|
@@ -160,8 +160,18 @@ export const regex = (expression) => helpers.withParams({expression}, (value) =>
|
|
|
160
160
|
return !!String(value).match(regexp);
|
|
161
161
|
});
|
|
162
162
|
|
|
163
|
+
const hasRequiredValue = (value) => {
|
|
164
|
+
if (value instanceof Array) {
|
|
165
|
+
return value.length > 0;
|
|
166
|
+
}
|
|
167
|
+
if (typeof value === 'string') {
|
|
168
|
+
return value.trim().length > 0;
|
|
169
|
+
}
|
|
170
|
+
return !isNil(value) && value !== false;
|
|
171
|
+
};
|
|
172
|
+
|
|
163
173
|
export const required = (value) => {
|
|
164
|
-
return
|
|
174
|
+
return hasRequiredValue(value);
|
|
165
175
|
};
|
|
166
176
|
|
|
167
177
|
export const requiredIf = (variable, expected, fieldName) => helpers.withParams({variable, expected}, function(value, data) {
|
|
@@ -174,7 +184,7 @@ export const requiredIf = (variable, expected, fieldName) => helpers.withParams(
|
|
|
174
184
|
expectedValue = expected === 'true' || expected === '1';
|
|
175
185
|
}
|
|
176
186
|
if (variableValue != expectedValue) return true;
|
|
177
|
-
return value
|
|
187
|
+
return hasRequiredValue(value);
|
|
178
188
|
});
|
|
179
189
|
|
|
180
190
|
export const requiredUnless = (variable, expected, fieldName) => helpers.withParams({variable, expected}, function(value, data) {
|
|
@@ -187,7 +197,7 @@ export const requiredUnless = (variable, expected, fieldName) => helpers.withPar
|
|
|
187
197
|
expectedValue = expected === 'true' || expected === '1';
|
|
188
198
|
}
|
|
189
199
|
if (variableValue == expectedValue) return true;
|
|
190
|
-
return value
|
|
200
|
+
return hasRequiredValue(value);
|
|
191
201
|
});
|
|
192
202
|
|
|
193
203
|
export const sameAs = (field, fieldName) => helpers.withParams({field}, function(value, data) {
|