Skip to content

Enhance FraudFundsTransferRequest with optional fields and validation…#414

Open
rcabrera-py wants to merge 3 commits into
mainfrom
feat/add-bank-code-and-payment-type
Open

Enhance FraudFundsTransferRequest with optional fields and validation…#414
rcabrera-py wants to merge 3 commits into
mainfrom
feat/add-bank-code-and-payment-type

Conversation

@rcabrera-py

@rcabrera-py rcabrera-py commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

… logic

  • Added optional fields: clabe, bank_code, and tipo_pago.
  • Implemented validation to ensure either clabe or bank_code is provided, and tipo_pago is required when bank_code is used.
  • Updated tests to cover new validation scenarios and parameterized input for better coverage.

Summary by CodeRabbit

  • New Features
    • Transfers can use an alternative bank identifier instead of CLABE and accept a new payment-type option for certain transfers.
  • Validation
    • New checks require either CLABE or the alternative bank identifier, and require the payment type when the alternative identifier is provided; clearer validation errors for invalid combinations.
  • Types & Enums
    • Added a validated bank-code type and a payment-type enum for allowed values.
  • Tests
    • Expanded tests to cover new input shapes and validation scenarios.

… logic

- Added optional fields: clabe, bank_code, and tipo_pago.
- Implemented validation to ensure either clabe or bank_code is provided, and tipo_pago is required when bank_code is used.
- Updated tests to cover new validation scenarios and parameterized input for better coverage.
@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

FraudFundsTransferRequest now accepts destination via either CLABE or bank_code with tipo_pago. The clabe field is now optional; new optional fields bank_code and tipo_pago were added. An after-model validator requires at least one of clabe or bank_code, and requires tipo_pago when bank_code is provided. A new FraudFundsTransferTipoPago IntEnum was introduced and exported. A BankCode annotated type and validator were added and exported. Tests were expanded with parametrized valid and invalid cases. Package version bumped to 2.1.38.dev2.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • rogelioLpz
  • gmorales96
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title clearly and specifically describes the main change: enhancing FraudFundsTransferRequest with optional fields and validation logic.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/add-bank-code-and-payment-type

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (cb83524) to head (4e2bede).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #414   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           16        16           
  Lines         1490      1509   +19     
=========================================
+ Hits          1490      1509   +19     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
cuenca_validations/types/__init__.py 100.00% <ø> (ø)
cuenca_validations/types/enums.py 100.00% <100.00%> (ø)
cuenca_validations/types/general.py 100.00% <100.00%> (ø)
cuenca_validations/types/requests.py 100.00% <100.00%> (ø)
cuenca_validations/version.py 100.00% <100.00%> (ø)

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cb83524...4e2bede. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
tests/test_types.py (1)

720-734: ⚡ Quick win

Add invalid cases for blank bank_code to lock the new contract.

Current invalid coverage misses bank_code='' / whitespace-only, which should fail under the “destination required” rule. Adding these cases will prevent regressions once the model validator is tightened.

Suggested test additions
 `@pytest.mark.parametrize`(
     'data, expected_error',
     [
         (dict(user_id='US123'), 'clabe or bank_code required'),
+        (
+            dict(user_id='US123', bank_code=''),
+            'clabe or bank_code required',
+        ),
+        (
+            dict(user_id='US123', bank_code='   '),
+            'clabe or bank_code required',
+        ),
         (
             dict(user_id='US123', bank_code='40012'),
             'tipo_pago required when using bank_code',
         ),
     ],
 )
🤖 Prompt for 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.

In `@tests/test_types.py` around lines 720 - 734, Test coverage misses
blank/whitespace-only bank_code cases: update the param list in
test_fraud_funds_transfer_request_invalid to include entries for
dict(user_id='US123', bank_code='') and dict(user_id='US123', bank_code='  ')
with expected_error 'clabe or bank_code required' so FraudFundsTransferRequest
validation (the model used in test_fraud_funds_transfer_request_invalid) rejects
empty/whitespace bank_code values.
🤖 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 `@cuenca_validations/types/requests.py`:
- Around line 330-340: validate_destination currently treats empty or
whitespace-only bank_code as present because it only checks for None; update the
validation to consider bank_code missing when it's None or blank/whitespace by
checking trimmed/string truthiness (e.g., treat bank_code as provided only if
bank_code and bank_code.strip()); use that same presence logic for both the
clabe-or-bank_code requirement and the tipo_pago dependency so that an empty
bank_code does not bypass the "clabe or bank_code required" rule and does not
trigger the tipo_pago-required branch incorrectly.

---

Nitpick comments:
In `@tests/test_types.py`:
- Around line 720-734: Test coverage misses blank/whitespace-only bank_code
cases: update the param list in test_fraud_funds_transfer_request_invalid to
include entries for dict(user_id='US123', bank_code='') and
dict(user_id='US123', bank_code='  ') with expected_error 'clabe or bank_code
required' so FraudFundsTransferRequest validation (the model used in
test_fraud_funds_transfer_request_invalid) rejects empty/whitespace bank_code
values.
🪄 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: CHILL

Plan: Pro

Run ID: 497b4363-fe43-4a81-b457-71dce0dbb1d0

📥 Commits

Reviewing files that changed from the base of the PR and between cb83524 and 7532356.

📒 Files selected for processing (3)
  • cuenca_validations/types/requests.py
  • cuenca_validations/version.py
  • tests/test_types.py

Comment thread cuenca_validations/types/requests.py Outdated
- Bumped version to 2.1.38.dev1.
- Introduced FraudFundsTransferTipoPago enum for payment types.
- Updated FraudFundsTransferRequest to use FraudFundsTransferTipoPago for tipo_pago field.
- Modified tests to validate new tipo_pago values.
- Introduced BankCode as a validated type for bank codes.
- Implemented validation logic to ensure bank codes are valid.
- Updated FraudFundsTransferRequest to use BankCode for the bank_code field.
- Enhanced tests to cover invalid bank code scenarios.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 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 `@cuenca_validations/types/general.py`:
- Line 5: The current import of BANK_NAMES and membership check in
validate_bank_code is using a non-public symbol; replace the usage with
clabe.get_bank_name(bank_code) instead: import get_bank_name (or call
clabe.get_bank_name) and call it inside validate_bank_code, treat any
falsy/exception result as invalid and raise the same validation error message
("Not a valid bank code"); ensure you remove the BANK_NAMES import and validate
that bank_code is the expected 3-digit code before calling get_bank_name to
match clabe's API.
🪄 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: CHILL

Plan: Pro

Run ID: a9821e9f-dcb7-40b7-9bf5-e2fd86757deb

📥 Commits

Reviewing files that changed from the base of the PR and between c1bee88 and 4e2bede.

📒 Files selected for processing (5)
  • cuenca_validations/types/__init__.py
  • cuenca_validations/types/general.py
  • cuenca_validations/types/requests.py
  • cuenca_validations/version.py
  • tests/test_types.py
🚧 Files skipped from review as they are similar to previous changes (3)
  • cuenca_validations/version.py
  • cuenca_validations/types/requests.py
  • tests/test_types.py

Comment thread cuenca_validations/types/general.py
@rcabrera-py rcabrera-py requested a review from gmorales96 June 12, 2026 20:17
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.

1 participant