import {FormControl} from '@angular/forms'; export class CustomValidators { static whiteSpaceValidator(control: FormControl) { const isWhitespace = (control.value || '').trim().length === 0; const isValid = !isWhitespace; return isValid ? null : {'whitespace': 'value is only whitespace'}; } static minAndMaxLengthValidator(control: FormControl) { const isMinLength = ((control.value || '').length < 2 || (control.value || '').length >= 20); const isValid = !isMinLength; return isValid ? null : {'Minlength': 'value is not equal to min length'}; } }