import { Validator, NG_VALIDATORS, FormControl } from '@angular/forms'
import { Directive, OnInit, forwardRef, Input } from '@angular/core';

import * as Globals from '../globals'; 
 
@Directive({
  selector: '[numberValue]',
  providers: [
    { provide: NG_VALIDATORS, useExisting: NumberValueValidator, multi: true }
  ]
})
export class NumberValueValidator implements Validator, OnInit {
 
    ngOnInit() {
    }
 
    validate(c: FormControl) {
   
        if (isNaN(+c.value)) {
          return { numberValue: true }
        }
    
        return null;
    }
}