2025-01-14 08:47:21 +01:00
|
|
|
import { AbstractControl, FormGroup, ValidationErrors, ValidatorFn } from "@angular/forms";
|
|
|
|
|
|
|
|
export class CrossValidator {
|
|
|
|
public onlyAllowNameAndDescriptionSame() {
|
|
|
|
return (control: AbstractControl): ValidationErrors | null => {
|
|
|
|
if (!(control instanceof FormGroup)) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
const name = control.get('name')?.value;
|
|
|
|
const description = control.get('description')?.value;
|
|
|
|
|
|
|
|
console.log(name, description);
|
|
|
|
|
|
|
|
const error = name !== description ? { mismatch: true } : null;
|
|
|
|
|
|
|
|
console.log(error);
|
|
|
|
|
|
|
|
return error;
|
|
|
|
};
|
|
|
|
}
|
2025-01-14 10:05:15 +01:00
|
|
|
|
|
|
|
public crossValidate() {
|
|
|
|
return (control: AbstractControl): ValidationErrors | null => {
|
|
|
|
if (!(control instanceof FormGroup)) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
const contactType = control.get('contactType')?.value;
|
|
|
|
|
|
|
|
if (contactType == "None") return null;
|
|
|
|
}
|
|
|
|
}
|
2025-01-14 08:47:21 +01:00
|
|
|
}
|