Use builtin number validation (#8819)

The regex approach doesn't work great for the many different number
formats. Even a simple decimal failed e.g. '1.1' was considered invalid.
I've switched this over to use javascripts builtin conversion and
validation. This now supports other formats e.g. '-1.0e15' would now be
considered valid.

Closes: #8820
This commit is contained in:
Nathaniel Brough
2024-12-03 00:03:49 +10:00
committed by GitHub
parent b6701a81e1
commit 64500d07d3

View File

@ -33,9 +33,9 @@ export const getSpreadSheetFieldValidationDefinitions = (
case FieldMetadataType.Number:
return [
{
rule: 'regex',
value: '^\\d+$',
errorMessage: fieldName + ' must be a number',
rule: 'function',
isValid: (value: string) => !isNaN(+value),
errorMessage: fieldName + ' is not valid',
level: 'error',
},
];