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