title: Angular 4 - Custom validator with dynamic parameter value
body: <p>I have written a custom validator that checks if a date is above a certain minimum date.</p>
  
  <p>the code looks like this:</p>
  
  <pre><code>export function validateMinDate(min: Date): ValidatorFn {
      return (c: AbstractControl) =&gt; {
  
          if (c == null || c.value == null)
              return null;
  
          let isValid = c.value &gt;= min;
          if (isValid) {
              return null;
          } else {
              return {
                  validateMinDate: {
                      valid: false
                  }
              };
          }
      };
  }
  </code></pre>
  
  <p>I initate my form like this</p>
  
  <pre><code>    this.definitionForm = this.fb.group({            
          "from": [this.details.From, Validators.required],
          "to": [this.details.To, [Validators.required, validateMinDate(this.details.From)]]
      });
  </code></pre>
  
  <p>I can see that the validator is being applied, but when I <code>console.log()</code> my min value in the validator I can see that it equal <code>null</code>.</p>
  
  <p><code>this.details.From</code> starts at null when I initiate the form, so I assume the parameter is not dynamic and just takes the value when the form is being set?</p>
  
  <p>How can I make sure the min date is being updated when a users picks a from date, and thus changes the value of <code>this.details.From</code>?</p>