title: Angular model-driven forms: Set custom validator in 'setValidators()'
body: <p>This is a small question, but it's has bothering me. </p>
  
  <p>I have a scene where I get a value (let's say a boolean) from outside the form, meaning it is not part of formgroup. And based on that value I want to set a custom validator, as it does not apply with the available ones (<code>required</code>,<code>pattern</code>...) Here is a <strong>very</strong> simplified code to showcase:
  So the problem is easy to set a required validator like so:</p>
  
  <pre><code>if(bool) {
     this.myForm.get('field').setValidators([Validators.required])
     this.myForm.get('field').updateValueAndValidity();
  } else ....
  </code></pre>
  
  <p>I would like a way to set a custom validation error instead. So something like:</p>
  
  <pre><code> this.myForm.get('field').setValidators([{notValid: true}])
  </code></pre>
  
  <p>But the above don't work, but I need to do that instead:</p>
  
  <pre><code> this.myForm.get('field').setValidators([this.customValidator])
  
   customValidator(field) {
     return {notValid: true}
   }
  </code></pre>
  
  <p>Is it not possible to set a custom validation on one line, instead of needing to having <code>customValidator</code>? (or any other better way)</p>
  
  <p>I know, small problem, but it's has been bothering me and code is also actually more complex than here.</p>
  
  <p>PS. I know I could do it and use for example one of the available Validators to mark it as invalid, but I would like clean solution if is possible.</p>