diff --git a/src/lib/isFloat.js b/src/lib/isFloat.js index e6cced044..643f9729f 100644 --- a/src/lib/isFloat.js +++ b/src/lib/isFloat.js @@ -5,7 +5,7 @@ export default function isFloat(str, options) { assertString(str); options = options || {}; const float = new RegExp(`^(?:[-+])?(?:[0-9]+)?(?:\\${options.locale ? decimal[options.locale] : '.'}[0-9]*)?(?:[eE][\\+\\-]?(?:[0-9]+))?$`); - if (str === '' || str === '.' || str === '-' || str === '+') { + if (str === '' || str === '.' || str === ',' || str === '-' || str === '+') { return false; } const value = parseFloat(str.replace(',', '.')); diff --git a/test/validators.test.js b/test/validators.test.js index 030765f34..64348cc34 100644 --- a/test/validators.test.js +++ b/test/validators.test.js @@ -4110,6 +4110,7 @@ describe('Validators', () => { ' ', '', '.', + ',', 'foo', '20.foo', '2020-01-06T14:31:00.135Z',