Skip to content

Accept hyphen grouping in credit_card validation - #1626

Open
official-burak wants to merge 1 commit into
go-playground:masterfrom
official-burak:fix/credit-card-hyphen-grouping
Open

Accept hyphen grouping in credit_card validation#1626
official-burak wants to merge 1 commit into
go-playground:masterfrom
official-burak:fix/credit-card-hyphen-grouping

Conversation

@official-burak

Copy link
Copy Markdown

Fixes Or Enhances

credit_card already splits on spaces before the Luhn check, so 4624 7482 3324 9780 is valid, but the same digits with hyphens are not. Hyphens are now treated as the same grouping separator, so Visa 4-4-4-4 and Amex 4-6-5 work. Double hyphens still fail, matching the existing double-space rule.

Fixes #1624

Make sure that you've checked the boxes below before you submit PR:

  • Tests exist or have been written that cover this particular change.

@go-playground/validator-maintainers

Spaces were already stripped before the Luhn check, so a number like 4624 7482 3324 9780 passed, but the same digits with hyphens did not. Hyphens are now treated as the same grouping separator. Double hyphens still fail, matching the existing double-space rule.

Fixes go-playground#1624
@official-burak
official-burak requested a review from a team as a code owner September 8, 2026 17:43
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.

Should credit_card validator support dash-separated card numbers?

1 participant