You simply pass the FormControl
an array of validators.
Here’s an example showing how you can add validators to an existing FormControl:
this.form.controls["firstName"].setValidators([Validators.minLength(1), Validators.maxLength(30)]);
Note, this will reset any existing validators you added when you created the FormControl
.
Angular 12 update
Since Angular 12, if you want to add new validators to the form without removing the existing validators, you can use addValidator
:
this.form.controls["firstName"].addValidators([Validators.minLength(1), Validators.maxLength(30)]);