Skip to content

NumberParser in 'de' does not return NaN for . as decimal separator #9086

@AnnaYuS

Description

@AnnaYuS

Provide a general summary of the issue here

In 'de' locale the decimal separator is , , so theoretically a string like '1234.7' is invalid number, so i'd expect NaN as a result but we get 1234.7

const parser = new NumberParser('de', { useGrouping: false })
console.log(parser.parse('1234.7')) // 1234.7

In 'en' it works as expected and gives back NaN if a wrong separator is used

const parser = new NumberParser('en', { useGrouping: false })
console.log(parser.parse('1234,7')) // NaN

🤔 Expected Behavior?

const parser = new NumberParser('de', { useGrouping: false })
console.log(parser.parse('1234.7')) // NaN

😯 Current Behavior

const parser = new NumberParser('de', { useGrouping: false })
console.log(parser.parse('1234.7')) // 1234.7

💁 Possible Solution

No response

🔦 Context

No response

🖥️ Steps to Reproduce

const parser = new NumberParser('de', { useGrouping: false })
console.log(parser.parse('1234.7'))

Version

^3.6.5

What browsers are you seeing the problem on?

Chrome

If other, please specify.

No response

What operating system are you using?

macos

🧢 Your Company/Team

No response

🕷 Tracking Issue

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions