mirror of
https://github.com/dzeiocom/FormManager.git
synced 2025-06-07 08:39:56 +00:00
Fix ToNumber
Signed-off-by: Avior <florian.bouillon@delta-wings.net>
This commit is contained in:
parent
ed5db58b89
commit
656528daa8
@ -26,7 +26,8 @@ export function toNumber(str: any): number | undefined {
|
||||
if (str === "" || typeof str !== "string") return undefined
|
||||
|
||||
// str is a string
|
||||
if ((str.startsWith("0") || str.startsWith("+")) && str.length > 1) return undefined
|
||||
const regex = new RegExp("^(0[0-9])|\\+")
|
||||
if (regex.test(str) && str.length > 1) return undefined
|
||||
const n = Number(str)
|
||||
if (!isNaN(n)) {
|
||||
return n
|
||||
|
Loading…
x
Reference in New Issue
Block a user