fix(parse): strict group sizes, and the symbol must match the currency

Open
#326 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
38/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
typescript
Domain
backend

Research direction

Read docs/reference/limitations.md and trace the parse implementation, comparing its grouping behavior with parseMoney and issue #138. Decide whether to add a lenient option and document that choice; add battery style vectors to spec/ once #321 lands, and update the CHANGELOG. Done when invalid group sizes are rejected, mismatched unambiguous currency symbols or codes throw SyntaxError, and the documented leniency behavior is covered by tests.

Written by the indexing model from the issue text.

Description

area: core

From docs/reference/limitations.md (Alex, 2026-11-13: worth doing soon).

parse is lenient in two ways a strict money parser shouldn't be:

  • it accepts misplaced group separators, such as 1,23,4.00 in en-US;

  • it doesn't check the currency symbol in the text against the currency argument, so parse('£12.50', 'EUR', 'en-GB') reads 12.50 EUR.

  • group sizes checked against the locale's (primary and secondary, as parseMoney and #138 already handle)

  • a symbol or code in the text that means another currency throws SyntaxError (unambiguous symbols only; a shared $ is accepted where the locale allows it)

  • a lenient option keeping today's behaviour, if that's needed for real inputs; decide and document

  • Visible change in the CHANGELOG; tests from the battery-style vectors (and add them to spec/ once #321 lands)

Dominant language
TypeScript
Stars
0
Forks
0
Avg merge
35m
Merged PRs (30d)
242

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from public/ducat

All issues in public/ducat

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.