diff --git a/src/process/validation/rules/__tests__/validateAvailableItems.test.ts b/src/process/validation/rules/__tests__/validateAvailableItems.test.ts index 42787ce0..de47bb42 100644 --- a/src/process/validation/rules/__tests__/validateAvailableItems.test.ts +++ b/src/process/validation/rules/__tests__/validateAvailableItems.test.ts @@ -125,6 +125,27 @@ it('Validating a simple static values select component with the available items expect(result).to.equal(null); }); +it('Validating a simple static values select component without the available items validation parameter will return null', async () => { + + const component: SelectComponent = { + ...simpleSelectOptions, + dataSrc: 'values', + data: { + values: [ + { label: 'foo', value: 'foo' }, + { label: 'bar', value: 'bar' } + ], + }, + validate: { onlyAvailableItems: false }, + }; + const data = { + component: 'baz', + }; + const context = generateProcessorContext(component, data); + const result = await validateAvailableItems(context); + expect(result).to.equal(null); +}); + it('Validating a simple URL select component without the available items validation parameter will return null', async () => { const component: SelectComponent = { ...simpleSelectOptions, diff --git a/src/process/validation/rules/validateAvailableItems.ts b/src/process/validation/rules/validateAvailableItems.ts index 4c7feb2c..5cad15c3 100644 --- a/src/process/validation/rules/validateAvailableItems.ts +++ b/src/process/validation/rules/validateAvailableItems.ts @@ -17,7 +17,7 @@ function isValidatableRadioComponent(component: any): component is RadioComponen function isValidateableSelectComponent(component: any): component is SelectComponent { return ( component && - !!component.validate?.hasOwnProperty('onlyAvailableItems') && + !!component.validate?.onlyAvailableItems && component.type === 'select' && component.dataSrc !== 'resource' );