WEB-680 Fix: Provisioning Criteria dialog allows negative values in age, percentage fields

This commit is contained in:
JaySoni1
2026-02-09 15:28:54 +05:30
parent 2f73e9a9eb
commit 2cb554ea00
4 changed files with 14 additions and 0 deletions
@@ -187,6 +187,7 @@ export class CreateLoanProvisioningCriteriaComponent implements OnInit {
value: definition ? definition.minAge : '', value: definition ? definition.minAge : '',
type: 'number', type: 'number',
required: true, required: true,
min: 0,
order: 1 order: 1
}) })
); );
@@ -197,6 +198,7 @@ export class CreateLoanProvisioningCriteriaComponent implements OnInit {
value: definition ? definition.maxAge : '', value: definition ? definition.maxAge : '',
type: 'number', type: 'number',
required: true, required: true,
min: 0,
order: 2 order: 2
}) })
); );
@@ -207,6 +209,7 @@ export class CreateLoanProvisioningCriteriaComponent implements OnInit {
value: definition ? definition.provisioningPercentage : '', value: definition ? definition.provisioningPercentage : '',
type: 'number', type: 'number',
required: true, required: true,
min: 0,
order: 3 order: 3
}) })
); );
@@ -195,6 +195,7 @@ export class EditLoanProvisioningCriteriaComponent implements OnInit {
value: definition ? definition.minAge : '', value: definition ? definition.minAge : '',
type: 'number', type: 'number',
required: true, required: true,
min: 0,
order: 1 order: 1
}) })
); );
@@ -205,6 +206,7 @@ export class EditLoanProvisioningCriteriaComponent implements OnInit {
value: definition ? definition.maxAge : '', value: definition ? definition.maxAge : '',
type: 'number', type: 'number',
required: true, required: true,
min: 0,
order: 2 order: 2
}) })
); );
@@ -215,6 +217,7 @@ export class EditLoanProvisioningCriteriaComponent implements OnInit {
value: definition ? definition.provisioningPercentage : '', value: definition ? definition.provisioningPercentage : '',
type: 'number', type: 'number',
required: true, required: true,
min: 0,
order: 3 order: 3
}) })
); );
@@ -34,6 +34,12 @@ export class FormGroupService {
if (formfield.required) { if (formfield.required) {
validators.push(Validators.required); validators.push(Validators.required);
} }
if (formfield.min !== null && formfield.min !== undefined) {
validators.push(Validators.min(formfield.min));
}
if (formfield.max !== null && formfield.max !== undefined) {
validators.push(Validators.max(formfield.max));
}
if (formfield.validators) { if (formfield.validators) {
formfield.validators.forEach((validator: ValidatorFn) => validators.push(validator)); formfield.validators.forEach((validator: ValidatorFn) => validators.push(validator));
} }
@@ -17,6 +17,8 @@
matInput matInput
[formControlName]="formfield.controlName" [formControlName]="formfield.controlName"
[required]="formfield.required" [required]="formfield.required"
[attr.min]="formfield.min"
[attr.max]="formfield.max"
/> />
} }
@if (form.controls[formfield.controlName].hasError('max')) { @if (form.controls[formfield.controlName].hasError('max')) {