title: Angular5 Custom Validator for Date Min
body: <p>I'm trying to create a validator for date input.</p>
  
  <p>so I've wrote this piece of code but it's not working as intended!</p>
  
  <pre><code>export class CustomValidators {
    static dateMinimum(date: string): ValidatorFn {
      return (control: AbstractControl): ValidationErrors | null =&gt; {
        if (control.value == null) {
          return null;
        }
  
        const controlDate = moment(control.value, FORMAT_DATE);
  
        if (!controlDate.isValid()) {
          return null;
        }
  
        const validationDate = moment(date);
  
        return controlDate.isAfter(validationDate) ? null : {
          'date-minimum': {
            'date-minimum': validationDate.format(FORMAT_DATE),
            'actual': controlDate.format(FORMAT_DATE)
          }
        };
      };
    }
  }
  </code></pre>
  
  <p>I'm getting this error</p>
  
  <pre><code>ERROR Error: Expected validator to return Promise or Observable.at toObservable (forms.js:749)
  </code></pre>
  
  <p>I don't really know which thing is not correct... I've found many examples on how to create a custom validators without parameters, but none with parameters...</p>
  
  <p>I need to use the validators like this:</p>
  
  <pre><code>    this.projectForm = this.builder.group({
        date: ['', Validators.required, CustomValidators.dateMinimum('2018-12-12')],
      });
  </code></pre>