diff --git a/src/process/validation/rules/__tests__/validateNumber.test.ts b/src/process/validation/rules/__tests__/validateNumber.test.ts index 25657c27..05b8ddef 100644 --- a/src/process/validation/rules/__tests__/validateNumber.test.ts +++ b/src/process/validation/rules/__tests__/validateNumber.test.ts @@ -39,3 +39,16 @@ it('Validating a multiple number with a blank value will return null', async () const result = await validateMultiple(context); expect(result).to.equal(null); }); + +it('Validating a multiple number with an empty array value will return null', async () => { + const component = { + ...simpleNumberField, + multiple: true + }; + const data = { + component: [], + }; + const context = generateProcessorContext(component, data); + const result = await validateMultiple(context); + expect(result).to.equal(null); +}); diff --git a/src/process/validation/rules/validateNumber.ts b/src/process/validation/rules/validateNumber.ts index fdeb597a..cacac2f7 100644 --- a/src/process/validation/rules/validateNumber.ts +++ b/src/process/validation/rules/validateNumber.ts @@ -11,6 +11,9 @@ export const shouldValidate = (context: ValidationContext) => { if (!value) { return false; } + if (component.multiple && Array.isArray(value) && value.length === 0) { + return false; + } if (!isValidatableNumberComponent(component)) { return false; }