Finally I found the solution:
New validation functions can be added to the form control state while preserving existing validations. To achieve this, you need to use the Validators.compose()
or Validators.composeAsync()
functions provided by Angular.
Here is an example of how you can add a new validation function while still retaining existing functions.
import { Validators, FormControl } from '@angular/forms';
// Assume you already have a form control with some existing validators
const myControl = new FormControl('', [
Validators.required,
Validators.minLength(3)
]);
// Define your new validation function
const emailValidator = Validators.email;
// Add the new validation function while keeping the existing validators intact
myControl.setValidators(Validators.compose([myControl.validator, emailValidator]));
myControl.updateValueAndValidity();