Is there a way for find out if an Angular FormControl has a validator and its value?
e.g. If I had a form control setup like this:
testControl: new FormControl(null, [Validators.required, Validators.minLength(5), Validators.maxLength(20)]),
Could I then check if the form control had the MaxLength validator, and more importantly, could I get out the maximum value.
I can do the following for the required validator:
const isRequired = this.formCtrl.hasValidator(Validators.required);
But how do I get the MaxValidator and its value.
Thanks
When maxLength is invalid, you can get the requiredLength value as follows;