title: remove custom validation dynamic into Angular 2
body: <blockquote>
    <p>i want set input required if checkbox is checked. validation working
    fine but  when i uncheck checkbox at that time i remove required
    validation. but form not valid and save button not enabled.</p>
  </blockquote>
  
  <p><strong>here my formbuilder.</strong></p>
  
  <pre><code>this.filterForm = this.formBuilder.group(
                  {
                      has_not_visited_in_days_group: this.formBuilder.group({
                          has_not_visited_in_days: [false],
                          has_not_visited_in_days_input: [''],
                      }, {validator: this.requiredIfHasNotVisitedChecked}),
                   });
  </code></pre>
  
  <p><strong>here custom validator function</strong></p>
  
  <pre><code>requiredIfHasNotVisitedChecked(control: AbstractControl): void {
          const input = control.get('has_not_visited_in_days_input').value;
          const inputCheckbox = control.get('has_not_visited_in_days').value;
          control.get('has_not_visited_in_days_input').setValidators([]);
          if (inputCheckbox) {
              if (input === '' || input === null) {
                  control.get('has_not_visited_in_days_input').setValidators([Validators.required]);
              }else {
                  control.get('has_not_visited_in_days_input').setValidators([]);
              }
          }else{
              control.get('has_not_visited_in_days_input').setValidators([]);
          }
      }
  </code></pre>
  
  <p><strong>also i tried</strong></p>
  
  <pre><code>  control.get('has_not_visited_in_days_input').setValidators(null);
  </code></pre>
  
  <p><strong><em>Thanks in advance. have any idea please help me.</em></strong></p>