fix(isTaxID): add formatted CPF support and additional test cases for pt-BR locale#2675
Conversation
- Update ptBrCheck function to validate both numeric and alphanumeric CNPJs - Add character-to-value conversion (A-Z → 17-42) - Maintain backward compatibility with numeric-only CNPJs - Add comprehensive tests for both formats Closes validatorjs#2639
- Update pt-BR regex to accept formatted CPF (XXX.XXX.XXX-XX) - Add formatting removal in ptBrCheck before validation - Reject all-equal-digit CPFs - Add comprehensive tests for valid and invalid CPFs Closes validatorjs#2645
|
I don't think the title or the description is correct. The only change I see is that we will also accept formatted ones (and adds some additional test cases for CPF). Is that correct? If so; please update the title and the description to reflect that. Also update the introductory text in lines 909-915 of the isTaxID.js file to reflect that we also strip the formatting. |
|
Updated! Title, description and the comment block in isTaxID.js now reflect the actual scope of the changes. Thanks for the review. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2675 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 114 114
Lines 2594 2595 +1
Branches 659 659
=========================================
+ Hits 2594 2595 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Description
This PR extends the existing CPF validation in the
pt-BRlocaleto also accept formatted CPF input (
XXX.XXX.XXX-XX), and addscomprehensive test cases for both formatted and unformatted CPFs.
Continuation of PR #2644.
Changes
pt-BRregex to also match formatted CPF (XXX.XXX.XXX-XX)ptBrCheckbefore validationTesting
Checklist
Closes #2645