Skip to content

Instantly share code, notes, and snippets.

@av1v3k
Last active March 8, 2024 02:37
Show Gist options
  • Save av1v3k/ddd385d75e8efc2e5509101e083334f5 to your computer and use it in GitHub Desktop.
Save av1v3k/ddd385d75e8efc2e5509101e083334f5 to your computer and use it in GitHub Desktop.
re-trigger Validation in angular form after patching
Object.values(this.anyform.controls).filter(control => {
if (control.invalid) {
control.patchValue(control?.value?.length === 0 ? ' ' : control?.value);
control.markAsDirty();
control.markAsTouched();
control.setErrors({ incorrect: true });
control.updateValueAndValidity();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment