public noWhitespaceValidator(control: FormControl) {
const isWhitespace = (control.value || '').trim().length === 0;
const isValid = !isWhitespace;
return isValid ? null : { 'whitespace': true };
}
<div *ngIf="yourForm.hasError('whitespace')">Please enter valid data</div>
new FormControl(field.fieldValue || '', [Validators.required, this.noWhitespaceValidator])