WEB-699 Fund Mapping: Loan Status and Product fields should be optional for search

This commit is contained in:
JaySoni1
2026-02-10 23:44:10 +05:30
parent f67aa7be90
commit 44a42b3086
@@ -28,9 +28,7 @@ import {
UntypedFormBuilder, UntypedFormBuilder,
UntypedFormControl, UntypedFormControl,
Validators, Validators,
ReactiveFormsModule, ReactiveFormsModule
AbstractControl,
ValidationErrors
} from '@angular/forms'; } from '@angular/forms';
import { ActivatedRoute, RouterLink } from '@angular/router'; import { ActivatedRoute, RouterLink } from '@angular/router';
@@ -122,39 +120,14 @@ export class FundMappingComponent implements OnInit {
this.buildDependencies(); this.buildDependencies();
} }
/**
* Custom validator to ensure array fields are not empty.
* @param {AbstractControl} control - the form control to validate.
* @returns {ValidationErrors | null} - validation errors or null if valid.
*/
private nonEmptyArrayValidator(control: AbstractControl): ValidationErrors | null {
const value = control.value;
if (!value || !Array.isArray(value) || value.length === 0) {
return { required: true };
}
if (value.every((item: any) => item === '' || item === null || item === undefined)) {
return { required: true };
}
return null;
}
/** /**
* Creates the Fund Mapping Form * Creates the Fund Mapping Form
*/ */
createFundMappingForm() { createFundMappingForm() {
this.fundMappingForm = this.formBuilder.group({ this.fundMappingForm = this.formBuilder.group({
loanStatus: [ loanStatus: [[]],
[], loanProducts: [[]],
this.nonEmptyArrayValidator.bind(this) offices: [[]],
],
loanProducts: [
[],
this.nonEmptyArrayValidator.bind(this)
],
offices: [
[],
this.nonEmptyArrayValidator.bind(this)
],
loanDateOption: [ loanDateOption: [
'', '',
Validators.required Validators.required