Fix isNumericString incorrectly accepting strings with surrounding whitespace
This commit is contained in:
parent
3b40955b02
commit
47415dc46a
2 changed files with 5 additions and 1 deletions
|
|
@ -688,7 +688,7 @@ export function isNumber(value: unknown): value is number {
|
|||
}
|
||||
|
||||
export function isNumericString(value: unknown): value is `${number}` {
|
||||
return isString(value) && !isEmptyStringOrWhitespace(value) && !Number.isNaN(Number(value));
|
||||
return isString(value) && !isEmptyStringOrWhitespace(value) && value === value.trim() && !Number.isNaN(Number(value));
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-restricted-types
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue