Skip to content

Conversation

@JaySoni1
Copy link
Contributor

@JaySoni1 JaySoni1 commented Jan 11, 2026

Changes Made :-

-Added min="0" attribute to the input fields for "On arrears ageing", "Overdue days for NPA", and "Principal Threshold (%) for Last Installment" to prevent users from entering negative values.
-Added Angular form validation (Validators.min(0)) for the above fields to ensure negative values are not accepted at the form level.

WEB-568

Before :-
image

After :-
image

Summary by CodeRabbit

  • Bug Fixes
    • Prevented negative value inputs for grace on arrears ageing, overdue days for NPA, and principal threshold for last installment in the loan product settings form through enhanced validation checks.

✏️ Tip: You can customize this high-level summary in your review settings.

…NPA, and Principal Threshold Fields in Loan Product Settings
@coderabbitai
Copy link

coderabbitai bot commented Jan 11, 2026

Note

.coderabbit.yaml has unrecognized properties

CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.

⚠️ Parsing warnings (1)
Validation error: Unrecognized key(s) in object: 'pre_merge_checks'
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Walkthrough

The PR adds minimum value constraints to three numeric fields in the loan product settings form by adding min="0" attributes to HTML inputs and Validators.min(0) to corresponding form controls to prevent negative values.

Changes

Cohort / File(s) Summary
Loan Product Settings Form Validation
src/app/products/loan-products/loan-product-stepper/loan-product-settings-step/loan-product-settings-step.component.html
Added min="0" constraint to three numeric input fields: graceOnArrearsAgeing, overdueDaysForNPA, and principalThresholdForLastInstallment at the template level.
Loan Product Settings Form Controls
src/app/products/loan-products/loan-product-stepper/loan-product-settings-step/loan-product-settings-step.component.ts
Added Validators.min(0) validator to the same three form controls in createLoanProductSettingsForm method, replacing bare string initializers with validator arrays.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • IOhacker
  • alberto-art3ch
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding validation to prevent negative values for three specific numeric fields in the loan product settings form.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing touches
  • 📝 Generate docstrings

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.

❤️ Share

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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
src/app/products/loan-products/loan-product-stepper/loan-product-settings-step/loan-product-settings-step.component.html (3)

385-385: Consider adding validation error messages for better UX.

The min="0" attribute provides client-side validation, but users won't see feedback when they enter invalid values. Consider adding error display logic similar to other fields in this template (e.g., lines 209-221 for disbursedAmountPercentageForDownPayment).

💡 Example error message implementation
 <mat-form-field class="flex-48">
   <mat-label>{{ 'labels.inputs.On arrears ageing' | translate }}</mat-label>
   <input type="number" min="0" matInput formControlName="graceOnArrearsAgeing" />
+  @if (loanProductSettingsForm.controls.graceOnArrearsAgeing.hasError('min')) {
+    <mat-error>
+      {{ 'labels.inputs.On arrears ageing' | translate }} {{ 'labels.commons.must be' | translate }}
+      <strong>{{ 'labels.commons.non-negative' | translate }}</strong>
+    </mat-error>
+  }
 </mat-form-field>

Note: Ensure the translation keys exist in your translation files.


401-401: Consider adding validation error messages for better UX.

Similar to line 385, this field lacks user feedback for validation failures. Adding an error message would improve the user experience.

💡 Example error message implementation
 <mat-form-field class="flex-48">
   <mat-label>{{ 'labels.inputs.Overdue days for NPA' | translate }}</mat-label>
   <input type="number" min="0" matInput formControlName="overdueDaysForNPA" />
+  @if (loanProductSettingsForm.controls.overdueDaysForNPA.hasError('min')) {
+    <mat-error>
+      {{ 'labels.inputs.Overdue days for NPA' | translate }} {{ 'labels.commons.must be' | translate }}
+      <strong>{{ 'labels.commons.non-negative' | translate }}</strong>
+    </mat-error>
+  }
 </mat-form-field>

414-414: Consider adding validation error messages for better UX.

This field also lacks user feedback for validation failures. Adding an error message would complete the validation implementation.

💡 Example error message implementation
 <mat-form-field class="flex-48">
   <mat-label>{{ 'labels.inputs.Principal Threshold (%) for Last Instalment' | translate }}</mat-label>
   <input type="number" min="0" matInput formControlName="principalThresholdForLastInstallment" />
+  @if (loanProductSettingsForm.controls.principalThresholdForLastInstallment.hasError('min')) {
+    <mat-error>
+      {{ 'labels.inputs.Principal Threshold (%) for Last Instalment' | translate }} {{ 'labels.commons.must be' | translate }}
+      <strong>{{ 'labels.commons.non-negative' | translate }}</strong>
+    </mat-error>
+  }
 </mat-form-field>
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dc1f75b and a0f2a5b.

📒 Files selected for processing (2)
  • src/app/products/loan-products/loan-product-stepper/loan-product-settings-step/loan-product-settings-step.component.html
  • src/app/products/loan-products/loan-product-stepper/loan-product-settings-step/loan-product-settings-step.component.ts
🧰 Additional context used
📓 Path-based instructions (1)
src/app/**

⚙️ CodeRabbit configuration file

src/app/**: For Angular code: verify component separation, trackBy on *ngFor,
strict type safety, and clean observable patterns.

Files:

  • src/app/products/loan-products/loan-product-stepper/loan-product-settings-step/loan-product-settings-step.component.html
  • src/app/products/loan-products/loan-product-stepper/loan-product-settings-step/loan-product-settings-step.component.ts
🧠 Learnings (2)
📓 Common learnings
Learnt from: alberto-art3ch
Repo: openMF/web-app PR: 2876
File: src/app/loans/loans-view/loan-account-actions/loan-reaging/loan-reaging.component.ts:91-94
Timestamp: 2025-12-09T14:24:31.429Z
Learning: In the LoanReagingComponent (src/app/loans/loans-view/loan-account-actions/loan-reaging/loan-reaging.component.ts), the transactionAmount field uses both Validators.min and Validators.max set to the same value (loanTransactionData.amount). This is intentional - it requires users to enter the exact amount as a confirmation/validation step before submitting the re-age operation.
📚 Learning: 2025-12-09T14:24:31.429Z
Learnt from: alberto-art3ch
Repo: openMF/web-app PR: 2876
File: src/app/loans/loans-view/loan-account-actions/loan-reaging/loan-reaging.component.ts:91-94
Timestamp: 2025-12-09T14:24:31.429Z
Learning: In the LoanReagingComponent (src/app/loans/loans-view/loan-account-actions/loan-reaging/loan-reaging.component.ts), the transactionAmount field uses both Validators.min and Validators.max set to the same value (loanTransactionData.amount). This is intentional - it requires users to enter the exact amount as a confirmation/validation step before submitting the re-age operation.

Applied to files:

  • src/app/products/loan-products/loan-product-stepper/loan-product-settings-step/loan-product-settings-step.component.html
  • src/app/products/loan-products/loan-product-stepper/loan-product-settings-step/loan-product-settings-step.component.ts
🔇 Additional comments (1)
src/app/products/loan-products/loan-product-stepper/loan-product-settings-step/loan-product-settings-step.component.ts (1)

316-328: LGTM! Form validators correctly implemented.

The addition of Validators.min(0) to these three form controls is correctly implemented and aligns with the corresponding HTML min="0" attributes. This provides both client-side and application-level validation to prevent negative values.

The validator syntax follows Angular best practices, and the empty string initial value allows these fields to remain optional while still enforcing non-negative values when populated.

Copy link
Contributor

@IOhacker IOhacker left a comment

Choose a reason for hiding this comment

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

Lgtm

@IOhacker IOhacker merged commit bb26080 into openMF:dev Jan 11, 2026
4 checks passed
@JaySoni1
Copy link
Contributor Author

@IOhacker Thank You for the review

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