diff --git a/src/process/validation/rules/__tests__/validateNumber.test.ts b/src/process/validation/rules/__tests__/validateNumber.test.ts index 6ca89ccb..25657c27 100644 --- a/src/process/validation/rules/__tests__/validateNumber.test.ts +++ b/src/process/validation/rules/__tests__/validateNumber.test.ts @@ -4,6 +4,7 @@ import { FieldError } from 'error'; import { simpleNumberField } from './fixtures/components'; import { generateProcessorContext } from './fixtures/util'; import { validateNumber } from '../validateNumber'; +import { validateMultiple } from '../validateMultiple'; it('Validating a valid number will return null', async () => { const component = simpleNumberField; @@ -25,3 +26,16 @@ it('Validating an invalid number will return a FieldError', async () => { expect(result).to.be.instanceOf(FieldError); expect(result?.errorKeyOrMessage).to.contain('number'); }); + +it('Validating a multiple number with a blank value will return null', async () => { + const component = { + ...simpleNumberField, + multiple: true + }; + const data = { + component: [null], + }; + 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 283bb9ce..fdeb597a 100644 --- a/src/process/validation/rules/validateNumber.ts +++ b/src/process/validation/rules/validateNumber.ts @@ -25,7 +25,7 @@ export const validateNumberSync: RuleFnSync = (context: ValidationContext) => { const error = new FieldError('number', context); const { value } = context; - if (typeof value !== 'number') { + if (value && typeof value !== 'number') { return error; } return null;