Skip to content

ro/cf: strip RO country prefix in compact() for consistent output#499

Open
gaoflow wants to merge 1 commit into
arthurdejong:masterfrom
gaoflow:fix-ro-cf-compact
Open

ro/cf: strip RO country prefix in compact() for consistent output#499
gaoflow wants to merge 1 commit into
arthurdejong:masterfrom
gaoflow:fix-ro-cf-compact

Conversation

@gaoflow

@gaoflow gaoflow commented Jun 24, 2026

Copy link
Copy Markdown

Description

Fixes #485. stdnum.ro.cf produced inconsistent output depending on whether the optional RO country prefix was present in the input:

>>> validate('RO 185 472 90')
'RO18547290'          # before
>>> validate('185 472 90')
'18547290'

Both inputs denote the same number, but compact() did not strip the RO prefix the way the cui.compact() it delegates to (and other country modules such as pl/nip) do.

Fix

  • compact() now strips the RO prefix, returning the domestic form — matching cui.compact() and sibling modules.
  • validate() is simplified: the manual RO split is removed since compact() now handles it.
  • The docstring example is updated to reflect '18547290'.

validate('RO 185 472 90') and validate('185 472 90') now both return '18547290'.

This pull request was prepared with the assistance of AI, under my direction and review.

validate('RO 185 472 90') previously returned 'RO18547290' while
validate('185 472 90') returned '18547290' for the same number,
making the output format depend on the input form. compact() now
strips the optional RO VAT prefix so validate() always returns the
domestic CUI/CIF digits, consistent with cui.compact() and the
behaviour of other country modules such as pl/nip.

Closes arthurdejong#485.
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.

Inconsistent behavior with country prefixes

1 participant