Reputation: 154
Just going through the docs I noticed that the angular team has an example of cross-field validation where they call the file directive and have no directive decorator.
I am mentioning the file shared/identity-revealed.directive.ts
here: https://angular.io/guide/form-validation#cross-field-validation
Since I am using reactive forms only, I would never need to use this validation as a directive.
Does this make sense? Is it good practice? Why? If not, how would you fix it (i.e. where would you put the file)?
Upvotes: 0
Views: 166
Reputation: 137
Maybe I am also missing something, but the directive approach is not necessary for reactive forms since we are not focusing on the .html template.
Check this article and its final conclusion: Cross field validation
With reactive forms, we don’t need a directive. However, with template-driven forms, we need a directive that runs the validator so that we can add the validator directive to the template and run the validator.
Upvotes: 1