Created
June 3, 2021 13:22
-
-
Save Graniron/b16968b64c0c361374b786311e0478fd to your computer and use it in GitHub Desktop.
NG: hasValueValidator
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
const hasValueValidator = (formGroup: FormGroup) => { | |
const hasValue = (val: string | string[]) => Array.isArray(val) ? val.length > 0 : !!val; | |
const formIsFilled = Object.values(formGroup.value).some(hasValue); | |
return formIsFilled ? null : { empty: true }; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment