validator.js
validator.js copied to clipboard
feat(isCPF): add validation to Brazilian CPF
Description
Added a function to validate CPF numbers in src/lib/isCPF.js, ensuring they comply with the official validation algorithm. The function checks if the CPF has 11 numeric digits and if the verification digits are correctly calculated.
References
The validation follows the rules defined by the Brazilian Federal Revenue Service for CPF verification digit calculation.
Files Changed
src/lib/isCPF.js– Added the CPF validation functiontest/validators.test.js– Added unit tests
Checklist
- [x] PR contains only changes related; no stray files, etc.
- [x] README updated (where applicable)
- [x] Tests written (where applicable)
- [x] References provided in PR (where applicable)