Skip to content

feat: add Luhn validator constraint - #213

Merged
66Ton99 merged 1 commit into
formapro:1.7from
damienalexandre:LuhnFor17
Aug 20, 2026
Merged

66Ton99 merged 1 commit into
formapro:1.7from
damienalexandre:LuhnFor17

Conversation

@damienalexandre

Copy link
Copy Markdown
Contributor

Backport a9e4db3 into the 1.7 branch.

Add Luhn validator for client-side validation of credit card numbers
and other values (like SIRET) that must pass the Luhn algorithm.

- Add Luhn.js constraint following the existing pattern
- Add comprehensive tests in Luhn.test.js
- Update index.js to import the new constraint

The implementation follows Symfony's LuhnValidator.php logic:
- Validates that the value contains only digits
- Applies the Luhn algorithm to verify the checksum
- Rejects values with checksum of 0 or not divisible by 10

Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
@66Ton99
66Ton99 merged commit 896f185 into formapro:1.7 Aug 20, 2026
8 checks passed
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