Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handling commas and dots input in parseToken of Parser #7514

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

naronchen
Copy link
Contributor

@naronchen naronchen commented Dec 24, 2024

#7487

Right now I have any input consists only special characters returning a parseError or a quantity with isValid field being false.

this should be all the special characters.
/^[!@#$%^&*()_+-=[]{};':"\|,.<>/?]+$/;

Let me know if thats expected, or we wanna handle just the dots/comas occurrences

@naronchen naronchen requested review from a team, ColinKerr, hl662 and rschili as code owners December 24, 2024 23:03
@naronchen naronchen requested a review from MarcNeely December 24, 2024 23:03
@naronchen naronchen changed the title minor fix on parseToken in Parser handling comas and dots input in parseToken of Parser Dec 26, 2024
@hl662 hl662 changed the title handling comas and dots input in parseToken of Parser handling commas and dots input in parseToken of Parser Jan 3, 2025
Copy link
Contributor

@hl662 hl662 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mathieu-fournier I'll let you chime in on whether we should check only commas and dots, or check all special characters (and if the special characters mentioned are enough or we missing any)

@naronchen
Copy link
Contributor Author

naronchen commented Jan 3, 2025

Just pushed a slightly different fix because Mathieu asked to handle multiple dots and comas mixed into numbers
Now I got these tests cases returning parseError.UnableToConvertParseTokensToQuantity

      "10..",
      "1.2,,3..4...7",
      ",,3..",
      "12..34",
      "1.2.3",
      "..10",
      "1...2",
      "1..",
      "1..,",
      "10,20,30..40",
      "1..e2",
      "1e..2",
      "1e2..",
      "1...2e3",
      "1e2..,3",

the ones with comas is a bit tricky

     "1,,2", // returns 12
     "1.,2", // returns 1.2

the parsing skips comas because the parsing method thinks its a thousands separator so it ignores it, will look into it more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants