diff --git a/src/lib/isNumeric.js b/src/lib/isNumeric.js index 4cc7ea5b3..313c96ecd 100644 --- a/src/lib/isNumeric.js +++ b/src/lib/isNumeric.js @@ -1,5 +1,5 @@ -import assertString from './util/assertString'; -import { decimal } from './alpha'; +import assertString from "./util/assertString"; +import { decimal } from "./alpha"; const numericNoSymbols = /^[0-9]+$/; @@ -8,5 +8,10 @@ export default function isNumeric(str, options) { if (options && options.no_symbols) { return numericNoSymbols.test(str); } - return (new RegExp(`^[+-]?([0-9]*[${(options || {}).locale ? decimal[options.locale] : '.'}])?[0-9]+$`)).test(str); + + const decimalSymbol = (options || {}).locale ? decimal[options.locale] : "."; + + return new RegExp( + `^[+-]?(?:\\d+|\\d*${decimalSymbol}\\d+)(?:[eE][+-]?\\d+)?$` + ).test(str); }