typescript whitespace validation] code example
Example 1: angular form validation whitespace
public noWhitespaceValidator(control: FormControl) {
const isWhitespace = (control.value || '').trim().length === 0;
const isValid = !isWhitespace;
return isValid ? null : { 'whitespace': true };
}
Example 2: angular form validation whitespace
<div *ngIf="yourForm.hasError('whitespace')">Please enter valid data</div>