title: Conditionally implement validation in form fields of an Angular 2 reactive form
body: <p>Can I conditionally implement validation in Angular 2 reactive form. I have this reactive form with 3 formControl fields one is a selection and the other two are input text for first name and last name. I want to conditionally implements validation for firstname and lastname based on the selection of the first field which is 'validateBy'. If the user selects 'byFirstName' only firstName should be validated. If the user selects 'byLastName'  only lastName should be validated. If the user selects 'byBoth' both firstName and lastName should be validated. I created a plunker for this. Only validation byBoth works.</p>
  
  <pre><code>ngOnInit() {
  this.myForm = this._fb.group({
    validateBy: ['byFirstName'],
    firstName:  ['', isFirstNameValid(() =&gt; (this.validateBy === 'byFirstName' || this.validateBy === 'byBoth'),
                       Validators.required)],
    lastName: ['', isLastNameValid(() =&gt; (this.validateBy === 'byLastName' || this.validateBy === 'byBoth'),
                       Validators.required)],
  }); 
  </code></pre>
  
  <p><a href="https://plnkr.co/edit/X0zOGf?p=preview" rel="noreferrer">https://plnkr.co/edit/X0zOGf?p=preview</a></p>