Skip to content

Add payment card scheme validation - #122

Merged
strider2038 merged 1 commit into
mainfrom
feat/card-scheme
Oct 2, 2026
Merged

strider2038 merged 1 commit into
mainfrom
feat/card-scheme

Conversation

@strider2038

Copy link
Copy Markdown
Contributor

Adds card-number scheme validation through it.IsCardScheme, validate.CardScheme, and is.CardScheme. Callers explicitly select one or more of 12 schemes; for example, it.IsCardScheme(validate.CardSchemeVisa, validate.CardSchemeMastercard) accepts either scheme's prefix and length rules.

Patterns follow Symfony 8.0, including legacy formats. Only ASCII digits are accepted, without stripping whitespace or hyphens. Checksum validation remains separate via it.IsLUHN(); this does not verify card existence or payment availability.

Includes typed scheme constants, custom errors/messages, validation groups, generic This/Each support, English/Russian translations, examples, README documentation, and an Unreleased changelog entry. Empty values are skipped. Empty or unknown scheme selections are configuration errors, a documented stricter policy than Symfony. Nonnumeric and nonmatching inputs share one violation error. No dependencies added.

Validation: bash scripts/test-all.sh passed (formatting, vet, golangci-lint v2.13.2, unit and race tests, module tidy and verification). Tests cover all schemes, prefix boundaries and allowed lengths, malformed input, multiple selections, caller slice isolation, translations, and independent LUHN checks.

Closes #105.

@strider2038
strider2038 merged commit fa79d90 into main Oct 2, 2026
4 checks passed
@strider2038
strider2038 deleted the feat/card-scheme branch October 2, 2026 14:40
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.

Constraint: CardScheme

1 participant