diff --git a/packages/common/src/editorValidators/floatValidator.ts b/packages/common/src/editorValidators/floatValidator.ts index b02c1cb8f..500dc6719 100644 --- a/packages/common/src/editorValidators/floatValidator.ts +++ b/packages/common/src/editorValidators/floatValidator.ts @@ -35,7 +35,7 @@ export function floatValidator(inputValue: any, options: FloatValidatorOptions): } else if (isRequired && inputValue === '') { isValid = false; outputMsg = errorMsg || Constants.VALIDATION_REQUIRED_FIELD; - } else if (inputValue !== '' && (isNaN(inputValue as number) || (decPlaces === 0 && !/^[-+]?(\d+(\.)?(\d)*)$/.test(inputValue)))) { + } else if (inputValue !== '' && (isNaN(inputValue as number) || (decPlaces === 0 && !/^[-+]?(\d*(\.)?(\d)*)$/.test(inputValue)))) { // when decimal value is 0 (which is the default), we accept 0 or more decimal values isValid = false; outputMsg = errorMsg || Constants.VALIDATION_EDITOR_VALID_NUMBER; diff --git a/packages/common/src/editors/__tests__/floatEditor.spec.ts b/packages/common/src/editors/__tests__/floatEditor.spec.ts index 140845e23..197ce7c2f 100644 --- a/packages/common/src/editors/__tests__/floatEditor.spec.ts +++ b/packages/common/src/editors/__tests__/floatEditor.spec.ts @@ -598,6 +598,14 @@ describe('FloatEditor', () => { expect(validation).toEqual({ valid: true, msg: '' }); }); + + it('should return True when field is required and field is a valid decimal value without 0 suffix', () => { + mockColumn.internalColumnEditor.required = true; + editor = new FloatEditor(editorArguments); + const validation = editor.validate('.5'); + + expect(validation).toEqual({ valid: true, msg: '' }); + }); }); }); }); diff --git a/packages/vanilla-bundle/dist-grid-bundle-zip/slickgrid-vanilla-bundle.zip b/packages/vanilla-bundle/dist-grid-bundle-zip/slickgrid-vanilla-bundle.zip index 7a05664c7..3fd5a777d 100644 Binary files a/packages/vanilla-bundle/dist-grid-bundle-zip/slickgrid-vanilla-bundle.zip and b/packages/vanilla-bundle/dist-grid-bundle-zip/slickgrid-vanilla-bundle.zip differ