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.js b/test/validators.js index 87f73ccd4..039ce70d4 100644 --- a/test/validators.js +++ b/test/validators.js @@ -3947,6 +3947,7 @@ describe('Validators', () => { ' ', '', '.', + ',', 'foo', '20.foo', '2020-01-06T14:31:00.135Z',