Skip to content

Instantly share code, notes, and snippets.

@Graniron
Created June 3, 2021 13:22
Show Gist options
  • Save Graniron/b16968b64c0c361374b786311e0478fd to your computer and use it in GitHub Desktop.
Save Graniron/b16968b64c0c361374b786311e0478fd to your computer and use it in GitHub Desktop.
NG: hasValueValidator
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