import { AbstractControl , ValidatorFn } from '@angular/forms' ; param length param regExp export function maskMinLengthValidator ( length , regExp = /[^a-zа-я0-9]+/g ) { return ( control ) : { [ key ] : any ; } | null => { let forbidden = false ; if ( control . value && typeof control . value === 'string' ) { forbidden = control . value . replace ( regExp , '' ) . length < length ; } return forbidden ? { minlength : { value : control . value } } : null ; } ; } param length param regExp export function maskMaxLengthValidator ( length , regExp = /[^a-zа-я0-9]+/g ) { return ( control ) : { [ key ] : any ; } | null => { let forbidden = false ; if ( control . value && typeof control . value === 'string' ) { forbidden = control . value . replace ( regExp , '' ) . length > length ; } return forbidden ? { minlength : { value : control . value } } : null ; } ; }