Skip to content

Instantly share code, notes, and snippets.

@andrewarosario
Last active December 18, 2023 19:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewarosario/90bfe581cb73d688655e27050b696041 to your computer and use it in GitHub Desktop.
Save andrewarosario/90bfe581cb73d688655e27050b696041 to your computer and use it in GitHub Desktop.
import { FormControl, ValidationErrors } from '@angular/forms';
export function trimmedRequiredValidator(control: FormControl<string>): ValidationErrors | null {
return !control.value || (control.value && control.value.trim() == '') ? { required: true } : null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment