I'm curious if anyone has found a way to trigger validation without using
updateValueAndValidity()
(which also triggers valueChanges
on a FormControl according to the docs which isn't always a desired behavior) or markAsTouched()
(which is simply incorrect as we didn't touch the control).
A workaround that comes to mind would be to extract validators logic in a way that it could be executed outside of FormControl and then do setErrors()
based on the results, but maybe there's a better way of doing that?
CodePudding user response:
See official doc:
https://angular.io/api/forms/AbstractControl#updateValueAndValidity
emitEvent: When true or not supplied (the default), both the statusChanges and valueChanges observables emit events with the latest status and value when the control is updated. When false, no events are emitted.
Edit: So you can validate without emitting an event.