From 4ba40969f439d2311aeff35f3439f6c05020dcbd Mon Sep 17 00:00:00 2001 From: johnformio Date: Tue, 29 Jul 2025 21:01:23 +0000 Subject: [PATCH] $'syncing commit from monorepo. PR: 332, Title: FIO-10379-10380: fixed an issue where validation, logic and conditions do not work property when the checkbox value is set as a string in conditions settings' --- src/process/__tests__/process.test.ts | 221 ++++++++++++++++++++++++++ src/utils/operators/IsEqualTo.js | 2 +- 2 files changed, 222 insertions(+), 1 deletion(-) diff --git a/src/process/__tests__/process.test.ts b/src/process/__tests__/process.test.ts index c1da0709..44f7137f 100644 --- a/src/process/__tests__/process.test.ts +++ b/src/process/__tests__/process.test.ts @@ -5806,6 +5806,227 @@ describe('Process Tests', function () { }); }); + it('Should return required validation error when the simple conditional value is set as a sting instead of boolean', async function () { + const form = { + key: 'form', + type: 'form', + input: true, + components: [ + { + label: 'Text Field', + placeholder: 'Text Field', + tableView: true, + defaultValue: 'Text Field Default Value', + validate: { + required: true, + }, + unique: true, + errorLabel: 'TF Custom Error Label', + key: 'textField', + properties: { + pdfLabel: 'Text Field PDF Label', + }, + conditional: { + show: true, + conjunction: 'all', + conditions: [ + { + component: 'triggerConditionalLogic', + operator: 'isEqual', + value: 'false', + }, + ], + }, + logic: [ + { + name: 'Non-required', + trigger: { + type: 'simple', + simple: { + show: true, + conjunction: 'all', + conditions: [ + { + component: 'triggerLogicMakeNonRequired', + operator: 'isEqual', + value: 'true', + }, + ], + }, + }, + actions: [ + { + name: 'Non-required', + type: 'property', + property: { + label: 'Required', + value: 'validate.required', + type: 'boolean', + }, + state: false, + }, + ], + }, + { + name: 'Disabled', + trigger: { + type: 'simple', + simple: { + show: true, + conjunction: 'all', + conditions: [ + { + component: 'triggerLogicMakeDisabled', + operator: 'isEqual', + value: 'true', + }, + ], + }, + }, + actions: [ + { + name: 'Disabled', + type: 'property', + property: { + label: 'Disabled', + value: 'disabled', + type: 'boolean', + }, + state: true, + }, + ], + }, + { + name: 'Change Value', + trigger: { + type: 'simple', + simple: { + show: true, + conjunction: 'all', + conditions: [ + { + component: 'checkbox4', + operator: 'isEqual', + value: 'true', + }, + ], + }, + }, + actions: [ + { + name: 'Change Value', + type: 'value', + value: 'value = "Modified Value";', + }, + ], + }, + ], + overlay: { + page: 1, + left: '100', + top: '300', + width: '400', + height: '30', + }, + type: 'textfield', + input: true, + }, + { + label: 'Trigger Conditional logic & hide components', + tableView: false, + defaultValue: false, + key: 'triggerConditionalLogic', + overlay: { + page: 1, + left: '100', + top: '1200', + width: '30', + height: '30', + }, + type: 'checkbox', + input: true, + }, + { + label: 'Trigger Logic & make non-required', + tableView: false, + defaultValue: false, + key: 'triggerLogicMakeNonRequired', + overlay: { + page: 1, + left: 100, + top: '1250', + width: '30', + height: '30', + }, + type: 'checkbox', + input: true, + }, + { + label: 'Trigger Logic & make disabled', + tableView: false, + key: 'triggerLogicMakeDisabled', + overlay: { + page: 1, + left: 100, + top: '1300', + width: '30', + height: '30', + }, + type: 'checkbox', + input: true, + defaultValue: false, + }, + { + label: 'Trigger Logic & change values (except File, Signature)', + tableView: false, + defaultValue: false, + key: 'checkbox4', + overlay: { + page: 1, + left: '100', + top: '1350', + width: '30', + height: '30', + }, + type: 'checkbox', + input: true, + }, + { + label: 'Submit', + tableView: false, + key: 'submit', + type: 'button', + input: true, + saveOnEnter: false, + }, + ], + }; + const submission = { + data: { + checkbox4: false, + submit: true, + textField: '', + triggerConditionalLogic: false, + triggerLogicMakeDisabled: false, + triggerLogicMakeNonRequired: false, + }, + state: 'submitted', + }; + const context = { + form, + submission, + data: submission.data, + components: form.components, + processors: Processors, + scope: {}, + config: { + server: true, + }, + }; + const scope = processSync(context as any); + expect((scope as ValidationScope).errors).to.have.length(1); + }); + describe('Required component validation in nested form in DataGrid/EditGrid', function () { const nestedForm = { key: 'form', diff --git a/src/utils/operators/IsEqualTo.js b/src/utils/operators/IsEqualTo.js index 24a6868e..9ab05fa2 100644 --- a/src/utils/operators/IsEqualTo.js +++ b/src/utils/operators/IsEqualTo.js @@ -20,7 +20,7 @@ export default class IsEqualTo extends ConditionOperator { return get(value, comparedValue, false); } if ( - value && + (value || value === false) && comparedValue && typeof value !== typeof comparedValue && isString(comparedValue)