angular validation not empty string 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
new FormControl(field.fieldValue || '', [Validators.required, this.noWhitespaceValidator])