import { FormControl } from '@angular/forms' ; export function requiredFileType ( type ) { return function ( control ) { const file = control . value ; if ( file ) { const extension = file . name . split ( '.' ) [ 1 ] . toLowerCase ( ) ; if ( type . toLowerCase ( ) !== extension . toLowerCase ( ) ) { return { requiredFileType : true } ; } return null ; } return null ; } ; }