Skip to content

isFloat() returns true when a combination of sign and decimal separator is passed #3

@Manu-2717

Description

@Manu-2717

Describe the bug
isFloat() returns true when a combination of sign and decimal separator is passed. E.g. "+."

Examples
Tested in REPL

This line only checks for "", ".", "-" and "+".
An effective solution is to use Regular Expression:

if (/^[+-]?[.٫]?$/.test(str)) {
  return false;
}

Might affect https://github.com/usarfoss/validator.js/pull/2020

Additional context
Validator.js version: v13.7.0
Node.js version: v16.6.1
OS platform: windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions