WEB-172 Merging all changes from main branch into dev branch (#2450)

This commit is contained in:
Gopi Kishan
2025-05-13 20:32:32 -06:00
committed by GitHub
parent c8d857f3cb
commit e643c64711
29 changed files with 331 additions and 95 deletions
@@ -0,0 +1,26 @@
import { AbstractControl, ValidatorFn } from '@angular/forms';
export function maxNumberValueValidator(maxControlName: string): ValidatorFn {
return (control: AbstractControl): { [key: string]: any } | null => {
const maxControl = control.parent?.get(maxControlName);
if (!maxControl || !control.value) {
return null;
}
let maxValue = maxControl.value;
if (typeof maxValue === 'undefined') {
return null;
}
if (typeof maxValue !== 'number') {
maxValue = maxValue * 1;
}
let controlValue = control.value;
if (typeof controlValue !== 'number') {
controlValue = controlValue * 1;
}
if (controlValue > maxValue) {
return { maxValue: { requiredMax: maxValue, actual: controlValue } };
}
return null;
};
}
@@ -0,0 +1,26 @@
import { AbstractControl, ValidatorFn } from '@angular/forms';
export function minNumberValueValidator(minControlName: string): ValidatorFn {
return (control: AbstractControl): { [key: string]: any } | null => {
const minControl = control.parent?.get(minControlName);
if (!minControl || !control.value) {
return null;
}
let minValue = minControl.value;
if (typeof minValue === 'undefined') {
return null;
}
if (typeof minValue !== 'number') {
minValue = minValue * 1;
}
let controlValue = control.value;
if (typeof controlValue !== 'number') {
controlValue = controlValue * 1;
}
if (controlValue < minValue) {
return { minValue: { requiredMin: minValue, actual: controlValue } };
}
return null;
};
}