[cpf-val] Create package to validate CPF#24
Conversation
Added email contact, refined summary, and provided a detailed description for the CPF validation utility. Included source code URI in the metadata for better accessibility. Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Introduced a comprehensive CPF validation module, including the `CpfValidator` class for validating CPF identifiers according to Brazilian standards. Added a helper method `cpf_val` for simplified usage. Implemented custom error handling with `TypeMismatchError` for API misuse. Enhanced documentation to clarify usage and error types. - Added support for both string and array inputs for CPF validation. - Included detailed comments and examples for better understanding. - Created a marker module for custom errors to streamline error handling. This update significantly improves the CPF validation utility, providing a robust and user-friendly API. Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Expanded the test suite for the CPF validation module by adding comprehensive tests for the `CpfValidator` class. Implemented various scenarios to validate CPF inputs, including valid, invalid, and edge cases. Introduced tests for error handling, ensuring that `TypeMismatchError` is raised for incorrect input types. - Added tests for both formatted and unformatted CPF inputs. - Included checks for repeated-digit prefixes and non-digit strings. - Verified the behavior of the `cpf_val` helper method against the `is_valid` method. This update significantly improves test coverage and robustness of the CPF validation functionality. Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (8)
📝 WalkthroughWalkthroughIntroduces the ChangesCPF validation package
Shared input predicates
Estimated code review effort: 3 (Moderate) | ~30 minutes Possibly related issues
Possibly related PRs
Suggested labels: Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/cpf-val/README.md`:
- Around line 155-163: The documented TypeMismatchError messages must match the
exact message asserted by cpf_val.spec.rb. Update the examples at
packages/cpf-val/README.md lines 155-163 and packages/cpf-val/README.pt.md lines
142-150 to use that exact message in their respective documentation examples.
- Around line 150-152: Complete the public error hierarchy and rescue guidance
in packages/cpf-val/README.md (lines 150-152 and 176-190) and
packages/cpf-val/README.pt.md (lines 137-139 and 163-177): document each error’s
full native inheritance chain and explicit CpfVal::Error inclusion, and add the
DomainError rescue case or explicitly state that the package defines no domain
errors; keep the English and Portuguese sections consistent.
In `@packages/cpf-val/src/cpf-val/types.rb`:
- Line 14: Update the public CpfInput definition in CpfVal so it no longer uses
the overly broad Object alias; remove it or replace it with a predicate that
matches the validator’s accepted Array<String> contract, ensuring numeric inputs
are rejected consistently with CpfValidator#is_valid.
In `@packages/cpf-val/tests/cpf_val.spec.rb`:
- Around line 55-87: Add a regression example in the public-types context that
calls described_class.cpf_val with a non-String/Array input such as 123 and
asserts it raises described_class::TypeMismatchError. Keep the existing
valid/invalid helper behavior and error-class coverage unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 1fa46a94-ff1a-44d8-a391-d38f95130c3c
📒 Files selected for processing (12)
packages/cpf-val/CHANGELOG.mdpackages/cpf-val/README.mdpackages/cpf-val/README.pt.mdpackages/cpf-val/cpf-val.gemspecpackages/cpf-val/src/cpf-val.rbpackages/cpf-val/src/cpf-val/cpf_val.rbpackages/cpf-val/src/cpf-val/cpf_validator.rbpackages/cpf-val/src/cpf-val/errors.rbpackages/cpf-val/src/cpf-val/types.rbpackages/cpf-val/tests/cpf_val.spec.rbpackages/cpf-val/tests/cpf_validator.spec.rbpackages/cpf-val/tests/errors.spec.rb
Adjustment as per @coderabbitai review comment at #24 (comment). Co-authored-by: CodeRabbit AI <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Adjustment as per @coderabbitai review comment at #24 (comment). Co-authored-by: CodeRabbit AI <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Fix as per @coderabbitai review comment at #24 (comment). Co-authored-by: CodeRabbit AI <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Fix as per @coderabbitai review comment at #24 (comment). Co-authored-by: CodeRabbit AI <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Fix as per @coderabbitai review comment at #24 (comment). Co-authored-by: CodeRabbit AI <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Fix as per @coderabbitai review comment at #24 (comment). Co-authored-by: CodeRabbit AI <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Adjustment as per @coderabbitai review comment at #24 (comment). Co-authored-by: CodeRabbit AI <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com>
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/cpf-fmt/README.md`:
- Line 425: Update the predicate examples to use fully qualified names: in
packages/cpf-fmt/README.md lines 425-425, use CpfFmt::CpfInput.accept? and
CpfFmt::CpfInput ===; in packages/cnpj-fmt/README.md lines 434-434 and
packages/cnpj-fmt/README.pt.md lines 419-419, use CnpjFmt::CnpjInput.accept? and
CnpjFmt::CnpjInput ===.
In `@packages/cpf-val/README.md`:
- Around line 127-133: The error hierarchy documentation is incomplete in both
README language versions. Update the TypeMismatchError summary in
packages/cpf-val/README.md:127-133 and packages/cpf-val/README.pt.md:114-120 to
show CpfVal::TypeMismatchError < TypeError < StandardError and explicitly
include CpfVal::Error, keeping the surrounding leaf-section content consistent
in each language.
- Around line 179-194: The rescue-granularity examples are incomplete and make
narrower handlers unreachable. In packages/cpf-val/README.md lines 179-194,
create separate standalone begin/rescue/end examples using CpfVal.cpf_val(123),
covering native TypeError, CpfVal::Error, and CpfVal::TypeMismatchError; retain
CpfVal::DomainError as explicitly not applicable. Mirror the same independently
scoped executable examples in packages/cpf-val/README.pt.md lines 166-182,
translated into Portuguese.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 86db9afd-1eef-4523-8006-b45bfab05040
📒 Files selected for processing (24)
packages/cnpj-fmt/README.mdpackages/cnpj-fmt/README.pt.mdpackages/cnpj-fmt/src/cnpj-fmt.rbpackages/cnpj-fmt/src/cnpj-fmt/types.rbpackages/cnpj-fmt/src/cnpj-fmt/utils.rbpackages/cnpj-fmt/tests/cnpj_fmt.spec.rbpackages/cnpj-val/README.mdpackages/cnpj-val/README.pt.mdpackages/cnpj-val/src/cnpj-val.rbpackages/cnpj-val/src/cnpj-val/cnpj_validator.rbpackages/cnpj-val/src/cnpj-val/types.rbpackages/cnpj-val/tests/cnpj_val.spec.rbpackages/cpf-fmt/README.mdpackages/cpf-fmt/README.pt.mdpackages/cpf-fmt/src/cpf-fmt.rbpackages/cpf-fmt/src/cpf-fmt/types.rbpackages/cpf-fmt/src/cpf-fmt/utils.rbpackages/cpf-fmt/tests/cpf_fmt.spec.rbpackages/cpf-val/README.mdpackages/cpf-val/README.pt.mdpackages/cpf-val/src/cpf-val.rbpackages/cpf-val/src/cpf-val/cpf_validator.rbpackages/cpf-val/src/cpf-val/types.rbpackages/cpf-val/tests/cpf_val.spec.rb
Adjustment as per @coderabbitai review comment at #24 (comment). Co-authored-by: CodeRabbit AI <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Adjustment as per @coderabbitai review comment at #24 (comment). Co-authored-by: CodeRabbit AI <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Adjustment as per @coderabbitai review comment at #24 (comment). Co-authored-by: CodeRabbit AI <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Adjustment as per @coderabbitai review comment at #24 (comment). Co-authored-by: CodeRabbit AI <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Adjustment as per @coderabbitai review comment at #24 (comment). Co-authored-by: CodeRabbit AI <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Adjustment as per @coderabbitai review comment at #24 (comment). Co-authored-by: CodeRabbit AI <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Adjustment as per @coderabbitai review comment at #24 (comment). Co-authored-by: CodeRabbit AI <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Fix as per @coderabbitai review comment at #24 (comment). Co-authored-by: CodeRabbit AI <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Adjustment as per @coderabbitai review comment at #24 (comment). Co-authored-by: CodeRabbit AI <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Adjustment as per @coderabbitai review comment at #24 (comment). Co-authored-by: CodeRabbit AI <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com>
[`cpf-val`] Create package to validate CPF
Fix as per @coderabbitai review comment at #24 (comment). Co-authored-by: CodeRabbit AI <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Adjustment as per @coderabbitai review comment at #24 (comment). Co-authored-by: CodeRabbit AI <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Adjustment as per @coderabbitai review comment at #24 (comment). Co-authored-by: CodeRabbit AI <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Adjustment as per @coderabbitai review comment at #24 (comment). Co-authored-by: CodeRabbit AI <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Adjustment as per @coderabbitai review comment at #24 (comment). Co-authored-by: CodeRabbit AI <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Fix as per @coderabbitai review comment at #24 (comment). Co-authored-by: CodeRabbit AI <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Adjustment as per @coderabbitai review comment at #24 (comment). Co-authored-by: CodeRabbit AI <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com>
[`cpf-val`] Create package to validate CPF
Fix as per @coderabbitai review comment at #24 (comment). Co-authored-by: CodeRabbit AI <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Adjustment as per @coderabbitai review comment at #24 (comment). Co-authored-by: CodeRabbit AI <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com>
[`cpf-val`] Create package to validate CPF
Resolves #10
Summary by CodeRabbit
Array<String>inputs.cpf_valhelper alongside the OO validator API; invalid CPF data returnsfalse.CpfInput,CnpjInput) withaccept?/===, plus structured type mismatch errors.