From e92c69b56ecafd2a3aebf4a368fac0646af50fb9 Mon Sep 17 00:00:00 2001 From: Michel Loew Date: Thu, 4 Jul 2024 11:40:13 +0200 Subject: [PATCH] FIX: Allow float-point numbers without decimal places in FloatValidator The current implementation of the floatValidator uses parseFloat, which strips decimal point and places if a whole number (eg. .0) is provided. This then causes the regex validation to fail because it always assumes there to be a decimal point and following decimal places. This change makes the decimal places in the regex-validation optional. --- packages/neos-ui-validators/src/Float/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/neos-ui-validators/src/Float/index.tsx b/packages/neos-ui-validators/src/Float/index.tsx index 19057a2e54..7cbbad35a4 100644 --- a/packages/neos-ui-validators/src/Float/index.tsx +++ b/packages/neos-ui-validators/src/Float/index.tsx @@ -8,7 +8,7 @@ interface FloatOptions { } const Float = (value: any, validatorOptions: FloatOptions) => { const number = parseFloat(value); - if (value !== null && value !== undefined && value.length !== 0 && ((isNaN(number) || value.toString().match(/^[-+]?[0-9]*\.[0-9]+([eE][-+]?[0-9]+)?$/) === null))) { + if (value !== null && value !== undefined && value.length !== 0 && ((isNaN(number) || value.toString().match(/^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$/) === null))) { const label = validatorOptions?.validationErrorMessage ?? 'content.inspector.validators.floatValidator.validFloatExpected'; return ; }