import { FormControl } from "@angular/forms" ; export function controlLengthValidator ( length ) { return ( control ) : { [ key ] : any ; } => { if ( control . value && control . value . length !== length ) { return { validLength : { valid : false } } ; } else { return null ; } } ; }