Created
March 14, 2022 09:16
-
-
Save Mustafa-Omran/8f96008e6a7099de7b26e5163e83aa1a to your computer and use it in GitHub Desktop.
Angular - No white spaces
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { FormControl } from "@angular/forms"; | |
export function noWhitespaceValidator(control: FormControl) { | |
const isWhitespace = (control.value || '').trim().length === 0; | |
const isValid = !isWhitespace; | |
return isValid ? null : { 'whitespace': true }; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment