@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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@processmaker/screen-builder",
3
- "version": "3.8.38",
3
+ "version": "3.8.39",
4
4
  "scripts": {
5
5
  "dev": "VITE_COVERAGE=true vite",
6
6
  "build": "vite build",
@@ -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 value instanceof Array ? value.length > 0 : !isNil(value) && value !== '' && value !== false;
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 instanceof Array ? value.length > 0 : !!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 instanceof Array ? value.length > 0 : !!value;
200
+ return hasRequiredValue(value);
191
201
  });
192
202
 
193
203
  export const sameAs = (field, fieldName) => helpers.withParams({field}, function(value, data) {