Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
221 changes: 221 additions & 0 deletions src/process/__tests__/process.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@
form: '65ea368b705068f84a93c87a',
};

const errors: any = [];

Check warning on line 901 in src/process/__tests__/process.test.ts

View workflow job for this annotation

GitHub Actions / publish

Unexpected any. Specify a different type
const context = {
_,
form,
Expand Down Expand Up @@ -1038,7 +1038,7 @@
},
},
};
const errors: any = [];

Check warning on line 1041 in src/process/__tests__/process.test.ts

View workflow job for this annotation

GitHub Actions / publish

Unexpected any. Specify a different type
const context = {
form,
submission,
Expand Down Expand Up @@ -1173,9 +1173,9 @@
},
};
processSync(context);
assert.equal((context.scope as any).errors.length, 2);

Check warning on line 1176 in src/process/__tests__/process.test.ts

View workflow job for this annotation

GitHub Actions / publish

Unexpected any. Specify a different type
assert.equal((context.scope as any).errors[0].ruleName, 'array');

Check warning on line 1177 in src/process/__tests__/process.test.ts

View workflow job for this annotation

GitHub Actions / publish

Unexpected any. Specify a different type
assert.equal((context.scope as any).errors[1].ruleName, 'required');

Check warning on line 1178 in src/process/__tests__/process.test.ts

View workflow job for this annotation

GitHub Actions / publish

Unexpected any. Specify a different type
});

it('Sets a value based on advanced conditions', async function () {
Expand Down Expand Up @@ -1274,7 +1274,7 @@
const submission = {
data: { test: '1' },
};
const context: any = {

Check warning on line 1277 in src/process/__tests__/process.test.ts

View workflow job for this annotation

GitHub Actions / publish

Unexpected any. Specify a different type
form,
submission,
data: submission.data,
Expand Down Expand Up @@ -1542,7 +1542,7 @@
form: '65e8786fc5dacf667eef12fc',
};

const errors: any = [];

Check warning on line 1545 in src/process/__tests__/process.test.ts

View workflow job for this annotation

GitHub Actions / publish

Unexpected any. Specify a different type
const context = {
form,
submission,
Expand Down Expand Up @@ -5806,6 +5806,227 @@
});
});

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 <i>(except File, Signature)</i>',
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',
Expand Down
2 changes: 1 addition & 1 deletion src/utils/operators/IsEqualTo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading