Skip to content

WEB-920 Add missing validation error messages and prevent negative values in recurring deposits form#3503

Merged
alberto-art3ch merged 1 commit into
openMF:devfrom
JaySoni1:WEB-920-add-missing-validation-error-messages-and-prevent-negative-values-in-recurring-deposits-form
Apr 14, 2026
Merged

WEB-920 Add missing validation error messages and prevent negative values in recurring deposits form#3503
alberto-art3ch merged 1 commit into
openMF:devfrom
JaySoni1:WEB-920-add-missing-validation-error-messages-and-prevent-negative-values-in-recurring-deposits-form

Conversation

@JaySoni1
Copy link
Copy Markdown
Contributor

@JaySoni1 JaySoni1 commented Apr 13, 2026

Changes Made :-

-Add validation error messages to required fields and restrict numeric inputs to non-negative values in recurring deposits account settings form when creating recurring deposit applications for client .

WEB-920

Before :-
image

image

After :-
image

image

Summary by CodeRabbit

  • Bug Fixes
    • Improved validation in the recurring deposits account settings form to prevent negative values and enforce positive integer inputs.
    • Added clearer required-field error messages for deposit period, deposit period frequency, and conditional deposit start date.
    • Constrained recurring frequency input to disallow negative entries and ensure consistent error feedback.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 13, 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

Template and component updates enforce positive-integer/minimum constraints and required validation messages for recurring-deposits account settings; the component imports a PositiveIntegerDirective and tightens TypeScript nullability on the reactive form property and control accessors.

Changes

Cohort / File(s) Summary
Recurring Deposits Template
src/app/deposits/recurring-deposits/.../recurring-deposits-account-settings-step.component.html
Added mifosxPositiveInteger to numeric inputs and min="0" for recurringFrequency; added <mat-error> messages for depositPeriod, depositPeriodFrequencyId, and conditional expectedFirstDepositOnDate.
Component Class
src/app/deposits/recurring-deposits/.../recurring-deposits-account-settings-step.component.ts
Imported/added PositiveIntegerDirective to imports; changed recurringDepositAccountSettingsForm to definite-assignment (!); added non-null assertions when accessing form controls (get(...)!) and in valueChanges subscriptions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • alberto-art3ch
  • IOhacker
🚥 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 changes: adding missing validation error messages and preventing negative values in the recurring deposits 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 unit tests (beta)
  • Create PR with unit tests

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
Copy Markdown
Collaborator

@alberto-art3ch alberto-art3ch left a comment

Choose a reason for hiding this comment

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

We have added a shared control InputPositiveIntegerComponent and directive mifosxPositiveNumber to positive numbers, please review this and use them

@JaySoni1
Copy link
Copy Markdown
Contributor Author

Ok @alberto-art3ch I will update the PR soon

@JaySoni1 JaySoni1 force-pushed the WEB-920-add-missing-validation-error-messages-and-prevent-negative-values-in-recurring-deposits-form branch from 6fcabde to 2af924c Compare April 14, 2026 15:59
@JaySoni1 JaySoni1 requested a review from alberto-art3ch April 14, 2026 16:00
@JaySoni1
Copy link
Copy Markdown
Contributor Author

@alberto-art3ch I have updated the PR please review

Copy link
Copy Markdown

@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: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/app/deposits/recurring-deposits/recurring-deposits-account-stepper/recurring-deposits-account-settings-step/recurring-deposits-account-settings-step.component.ts (1)

221-231: ⚠️ Potential issue | 🟠 Major

Restore required validators when re-adding frequency controls.

When isCalendarInherited toggles from true to false, the frequency controls are re-added without Validators.required, causing a silent loss of validation rules that exist in the initial form definition. This inconsistency allows invalid form submission when the calendar is no longer inherited.

Update lines 228–230 to match the initial validation rules:

Preserve validation rules on control re-addition
-          this.recurringDepositAccountSettingsForm.addControl('expectedFirstDepositOnDate', new UntypedFormControl());
-          this.recurringDepositAccountSettingsForm.addControl('recurringFrequency', new UntypedFormControl(''));
-          this.recurringDepositAccountSettingsForm.addControl('recurringFrequencyType', new UntypedFormControl(''));
+          this.recurringDepositAccountSettingsForm.addControl('expectedFirstDepositOnDate', new UntypedFormControl(''));
+          this.recurringDepositAccountSettingsForm.addControl('recurringFrequency', new UntypedFormControl('', Validators.required));
+          this.recurringDepositAccountSettingsForm.addControl('recurringFrequencyType', new UntypedFormControl('', Validators.required));
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/app/deposits/recurring-deposits/recurring-deposits-account-stepper/recurring-deposits-account-settings-step/recurring-deposits-account-settings-step.component.ts`
around lines 221 - 231, When handling isCalendarInherited valueChanges in the
recurring-deposits-account-settings-step component, re-add the removed controls
with the same validators they originally had instead of plain UntypedFormControl
instances; update the branch that runs when isCalendarInherited is false to add
expectedFirstDepositOnDate, recurringFrequency and recurringFrequencyType using
new UntypedFormControl(..., Validators.required) (or the exact validator set
used in the initial form definition) so recurringDepositAccountSettingsForm
regains the original required validation rules.
🧹 Nitpick comments (1)
src/app/deposits/recurring-deposits/recurring-deposits-account-stepper/recurring-deposits-account-settings-step/recurring-deposits-account-settings-step.component.ts (1)

57-57: Migrate form to typed FormGroup to enforce type safety.

Line 57's UntypedFormGroup weakens compile-time type guarantees throughout the component. Define a typed FormGroup interface for this form shape and use FormGroup<T> instead, ensuring strict type safety aligned with coding guidelines requiring strict TypeScript conventions for src/app/**/*.ts.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/app/deposits/recurring-deposits/recurring-deposits-account-stepper/recurring-deposits-account-settings-step/recurring-deposits-account-settings-step.component.ts`
at line 57, The form property recurringDepositAccountSettingsForm is declared as
UntypedFormGroup which loses compile-time safety; define a TypeScript interface
(e.g., RecurringDepositAccountSettingsFormValue) describing the controls and
their value types used in this component, replace UntypedFormGroup with
FormGroup<RecurringDepositAccountSettingsFormValue>, and update all places that
call this.recurringDepositAccountSettingsForm.get, .controls, .value,
patchValue, etc., to use the typed shape (or cast to the interface types) so the
component (and methods like any validators or submit handlers) benefit from
strict typing and compile-time checks.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@src/app/deposits/recurring-deposits/recurring-deposits-account-stepper/recurring-deposits-account-settings-step/recurring-deposits-account-settings-step.component.ts`:
- Around line 139-140: The patchValue call for the form control retrieved via
get('withHoldTax') is using this.recurringDepositsAccountTemplate and can pick
the wrong/undefined source when isNew uses
recurringDepositsAccountProductTemplate; change the source to the selected
account object (this.recurringDepositsAccount.withHoldTax) when patching the
control in the RecurringDepositsAccountSettingsStepComponent, and add a
safe/null check before calling patchValue so you only patch when
this.recurringDepositsAccount is defined.
- Around line 125-137: The component creates subscriptions to
withHoldTax.valueChanges in ngOnChanges/constructor without cleanup causing
leaks; implement OnDestroy, add a private destroy$: Subject<void> (or similar),
import takeUntil, and pipe all valueChanges subscriptions (including the one on
recurringDepositAccountSettingsForm.get('withHoldTax')) with
takeUntil(this.destroy$); call this.destroy$.next(); this.destroy$.complete() in
ngOnDestroy; alternatively, before creating a subscription check the control
exists and that you haven't already subscribed (e.g., guard on
recurringDepositAccountSettingsForm.contains('withHoldTax') or track
subscription refs) and unsubscribe/remove them when controls are removed (e.g.,
when removing 'taxGroupId').

---

Outside diff comments:
In
`@src/app/deposits/recurring-deposits/recurring-deposits-account-stepper/recurring-deposits-account-settings-step/recurring-deposits-account-settings-step.component.ts`:
- Around line 221-231: When handling isCalendarInherited valueChanges in the
recurring-deposits-account-settings-step component, re-add the removed controls
with the same validators they originally had instead of plain UntypedFormControl
instances; update the branch that runs when isCalendarInherited is false to add
expectedFirstDepositOnDate, recurringFrequency and recurringFrequencyType using
new UntypedFormControl(..., Validators.required) (or the exact validator set
used in the initial form definition) so recurringDepositAccountSettingsForm
regains the original required validation rules.

---

Nitpick comments:
In
`@src/app/deposits/recurring-deposits/recurring-deposits-account-stepper/recurring-deposits-account-settings-step/recurring-deposits-account-settings-step.component.ts`:
- Line 57: The form property recurringDepositAccountSettingsForm is declared as
UntypedFormGroup which loses compile-time safety; define a TypeScript interface
(e.g., RecurringDepositAccountSettingsFormValue) describing the controls and
their value types used in this component, replace UntypedFormGroup with
FormGroup<RecurringDepositAccountSettingsFormValue>, and update all places that
call this.recurringDepositAccountSettingsForm.get, .controls, .value,
patchValue, etc., to use the typed shape (or cast to the interface types) so the
component (and methods like any validators or submit handlers) benefit from
strict typing and compile-time checks.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 37f521a8-a035-40b2-b500-5e0de938e81b

📥 Commits

Reviewing files that changed from the base of the PR and between 6fcabde and 2af924c.

📒 Files selected for processing (2)
  • src/app/deposits/recurring-deposits/recurring-deposits-account-stepper/recurring-deposits-account-settings-step/recurring-deposits-account-settings-step.component.html
  • src/app/deposits/recurring-deposits/recurring-deposits-account-stepper/recurring-deposits-account-settings-step/recurring-deposits-account-settings-step.component.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/app/deposits/recurring-deposits/recurring-deposits-account-stepper/recurring-deposits-account-settings-step/recurring-deposits-account-settings-step.component.html

Copy link
Copy Markdown
Collaborator

@alberto-art3ch alberto-art3ch left a comment

Choose a reason for hiding this comment

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

LGTM

@alberto-art3ch alberto-art3ch merged commit 33b7290 into openMF:dev Apr 14, 2026
6 checks passed
@JaySoni1
Copy link
Copy Markdown
Contributor Author

@alberto-art3ch 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