mirror of
https://github.com/dzeiocom/FormManager.git
synced 2025-07-23 21:39:51 +00:00
@ -26,7 +26,8 @@ export function toNumber(str: any): number | undefined {
|
|||||||
if (str === "" || typeof str !== "string") return undefined
|
if (str === "" || typeof str !== "string") return undefined
|
||||||
|
|
||||||
// str is a string
|
// 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)
|
const n = Number(str)
|
||||||
if (!isNaN(n)) {
|
if (!isNaN(n)) {
|
||||||
return n
|
return n
|
||||||
|
Reference in New Issue
Block a user