Search code examples
angularangular2-forms

Angular2 get existing validators of a formcontrol


Lets say

surname = new FormControl('', [Validators.required, Validators.minLength(2)]);

At some point depending on the situation I may add or delete any validators on surname control.

At the end How do I know what validators exists on surname control? I couldn't find any thing in documentation nor by dumping the control into console

Something like

surname.getValidators() should return - ['required', 'minLength']

Solution

  • Reading validators from a control is currently not supported

    See also https://github.com/angular/angular/issues/13461