Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create directive to handle display of form validity #1

Open
samrichardsontylertech opened this issue May 20, 2022 · 0 comments · May be fixed by #2
Open

create directive to handle display of form validity #1

samrichardsontylertech opened this issue May 20, 2022 · 0 comments · May be fixed by #2
Labels
enhancement New feature or request

Comments

@samrichardsontylertech
Copy link
Contributor

samrichardsontylertech commented May 20, 2022

Describe the feature:
Currently showing the required and invalid status of a form field requires developers to set the required attribute of the element and bind to the invalid property, checking both the invalid and touched properties of the form control. For required, this involves setting the attribute separately from the form validators and increasing the risk of bugs. It also forces developers to remember the difference between touched and dirty and consistently implement the validity check correctly, increasing code repetition, the risk for bugs, and the cognitive burden of developing a front end.

These properties can instead be abstracted into an Angular directive that takes in a form control and listens for status updates, setting the properties based on the state of the control itself. This approach is already taken by a few teams and should be made available more widely. The directive could also be expanded on in the future to handle other form related features.

Describe any alternatives you've considered:
The alternative is to continue setting required and invalid manually, but as noted above this can be tedious and prone to bugs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant