import { AbstractControl } from '@angular/forms'; export class FieldSpaceValidator { static spaceValidator(control: AbstractControl) { // if (control && control.value && !control.value.replace(/\s/g, '').length) { // control.setValue(''); // } // return null; const isWhitespace = (control.value || '').trim().length === 0; const isValid = !isWhitespace; return isValid ? null : { '"whitespace"': true }; } }