import { Directive , forwardRef } from '@angular/core' ; import { NG_VALIDATORS , Validator , AbstractControl } from '@angular/forms' ; import { placa } from './validator' ; const PLACA_VALIDATOR = { provide : NG_VALIDATORS , useExisting : forwardRef ( ( ) => PLACAValidator ) , multi : true } ; @ Directive ( { selector : '[placa][formControlName],[placa][formControl],[placa][ngModel]' , providers : [ PLACA_VALIDATOR ] } ) export class PLACAValidator implements Validator { validate ( c ) { return placa ( c ) ; } }